{"id":28545529,"url":"https://github.com/pytest-dev/pytest-metadata","last_synced_at":"2025-07-07T05:31:58.481Z","repository":{"id":17510723,"uuid":"82121051","full_name":"pytest-dev/pytest-metadata","owner":"pytest-dev","description":"Plugin for accessing test session metadata","archived":false,"fork":false,"pushed_at":"2025-06-23T20:16:39.000Z","size":123,"stargazers_count":68,"open_issues_count":12,"forks_count":28,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-29T00:05:17.936Z","etag":null,"topics":["metadata","plugin","pytest"],"latest_commit_sha":null,"homepage":"https://pypi.python.org/pypi/pytest-metadata/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pytest-dev.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-16T00:28:12.000Z","updated_at":"2025-06-26T13:21:18.000Z","dependencies_parsed_at":"2023-11-13T22:22:31.502Z","dependency_job_id":"92c53083-d037-4493-878f-115164b656cf","html_url":"https://github.com/pytest-dev/pytest-metadata","commit_stats":{"total_commits":86,"total_committers":20,"mean_commits":4.3,"dds":0.6744186046511628,"last_synced_commit":"c7488f04103d8619845198718f1b02ae79728ceb"},"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/pytest-dev/pytest-metadata","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-metadata","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-metadata/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-metadata/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-metadata/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pytest-dev","download_url":"https://codeload.github.com/pytest-dev/pytest-metadata/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pytest-dev%2Fpytest-metadata/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262518106,"owners_count":23323301,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["metadata","plugin","pytest"],"created_at":"2025-06-09T23:07:59.983Z","updated_at":"2025-07-07T05:31:58.469Z","avatar_url":"https://github.com/pytest-dev.png","language":"Python","readme":"pytest-metadata\n===============\n\npytest-metadata is a plugin for `pytest \u003chttp://pytest.org\u003e`_ that provides\naccess to test session metadata.\n\n.. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg\n   :target: https://github.com/pytest-dev/pytest-metadata/blob/master/LICENSE\n   :alt: License\n.. image:: https://img.shields.io/pypi/v/pytest-metadata.svg\n   :target: https://pypi.python.org/pypi/pytest-metadata/\n   :alt: PyPI\n.. image:: https://img.shields.io/travis/pytest-dev/pytest-metadata.svg\n   :target: https://travis-ci.org/pytest-dev/pytest-metadata/\n.. image:: https://img.shields.io/badge/code%20style-black-000000.svg\n   :target: https://github.com/ambv/black\n   :alt: Travis\n.. image:: https://img.shields.io/github/issues-raw/pytest-dev/pytest-metadata.svg\n   :target: https://github.com/pytest-dev/pytest-metadata/issues\n   :alt: Issues\n.. image:: https://img.shields.io/requires/github/pytest-dev/pytest-metadata.svg\n   :target: https://requires.io/github/pytest-dev/pytest-metadata/requirements/?branch=master\n   :alt: Requirements\n\nRequirements\n------------\n\nYou will need the following in order to use pytest-metadata:\n\n- Python 3.8+ or PyPy3\n\nInstallation\n------------\n\nTo install pytest-metadata:\n\n.. code-block:: bash\n\n  $ pip install pytest-metadata\n\nContributing\n------------\n\nWe welcome contributions.\n\nTo learn more, see `Development \u003chttps://github.com/pytest-dev/pytest-metadata/blob/master/development.rst\u003e`_\n\nAvailable metadata\n------------------\n\nThe following metadata is gathered by this plugin:\n\n========  =============== ===================================\nKey       Description     Example\n========  =============== ===================================\nPython    Python version  3.6.4\nPlatform  Platform        Darwin-17.4.0-x86_64-i386-64bit\nPackages  pytest packages {'py': '1.5.2', 'pytest': '3.4.1'}\nPlugins   pytest plugins  {'metadata': '1.6.0'}\n========  =============== ===================================\n\nAdditional metadata\n-------------------\n\nYou can provide your own metadata (key, value pair) by specifying ``--metadata`` on the commandline::\n\n   pytest --metadata foo bar\n\nNote: You can provide multiple sets of ``--metadata``::\n\n   pytest --metadata foo bar --metadata baz zoo\n\nThere's also the possibility of passing in metadata as a JSON string::\n\n    pytest --metadata-from-json '{\"cat_says\": \"bring the cat nip\", \"human_says\": \"yes kitty\"}'\n\nAlternatively a JSON can be read from a given file::\n\n    pytest --metadata-from-json-file path/to/valid/file.json\n\nContinuous integration\n----------------------\n\nWhen run in a continuous integration environment, additional metadata is added\nfrom environment variables. Below is a list of the supported continuous\nintegration providers, along with links to the environment variables that are\nadded to metadata if they're present.\n\n* `AppVeyor \u003chttps://www.appveyor.com/docs/environment-variables/\u003e`_\n* `Bitbucket \u003chttps://confluence.atlassian.com/bitbucket/environment-variables-794502608.html\u003e`_\n* `CircleCI \u003chttps://circleci.com/docs/1.0/environment-variables/\u003e`_\n* `GitLab CI \u003chttp://docs.gitlab.com/ce/ci/variables/README.html\u003e`_\n* `Jenkins \u003chttps://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables\u003e`_\n* `TaskCluster \u003chttps://docs.taskcluster.net/reference/workers/docker-worker/environment\u003e`_\n* `Travis CI \u003chttps://docs.travis-ci.com/user/environment-variables/\u003e`_\n\nNote that if you're using `Tox \u003chttp://tox.readthedocs.io/\u003e`_ to run your tests\nthen you will need to `pass down any additional environment variables \u003chttp://tox.readthedocs.io/en/latest/example/basic.html#passing-down-environment-variables\u003e`_\nfor these to be picked up.\n\nViewing metadata\n----------------\n\nIf you pass ``--verbose`` on the command line when running your tests, then the\nmetadata will be displayed in the terminal report header::\n\n  pytest --verbose\n  ============================ test session starts ============================\n  platform darwin -- Python 3.6.4, pytest-3.4.1, py-1.5.2, pluggy-0.6.0 -- /usr/bin/python\n  cachedir: .pytest_cache\n  metadata: {'Python': '3.6.4', 'Platform': 'Darwin-17.4.0-x86_64-i386-64bit', 'Packages': {'pytest': '3.4.1', 'py': '1.5.2', 'pluggy': '0.6.0'}, 'Plugins': {'metadata': '1.6.0'}}\n  plugins: metadata-1.6.0\n\nIncluding metadata in Junit XML\n-------------------------------\n\nPytest-metadata provides the session scoped fixture :code:`include_metadata_in_junit_xml` that you may use to include any metadata in Junit XML as ``property`` tags.\nFor example the following test module\n\n.. code-block:: python\n\n  import pytest\n\n  pytestmark = pytest.mark.usefixtures('include_metadata_in_junit_xml')\n\n  def test():\n      pass\n\nwhen called with\n\n.. code-block:: bash\n\n  pytest --metadata Daffy Duck --junit-xml=results.xml\n\nwould produce the following XML\n\n.. code-block:: xml\n\n  \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n  \u003ctestsuites\u003e\n    \u003ctestsuite name=\"pytest\" errors=\"0\" failures=\"0\" skipped=\"0\" tests=\"1\" time=\"0.009\" timestamp=\"2020-11-27T06:38:44.407674\" hostname=\"sam\"\u003e\n      \u003cproperties\u003e\n        \u003cproperty name=\"Daffy\" value=\"Duck\"/\u003e\n  ...\n\nAccessing metadata\n------------------\n\nTo add/modify/delete metadata at the end of metadata collection, you can use the ``pytest_metadata`` hook:\n\n.. code-block:: python\n\n  import pytest\n  @pytest.hookimpl(optionalhook=True)\n  def pytest_metadata(metadata):\n      metadata.pop(\"password\", None)\n\nTo access the metadata from a test or fixture, you can use the ``metadata``\nfixture:\n\n.. code-block:: python\n\n  def test_metadata(metadata):\n      assert 'metadata' in metadata['Plugins']\n\nTo access the metadata from a plugin, you can use the ``stash`` attribute of\nthe ``config`` object. This can be used to read/add/modify the metadata:\n\n.. code-block:: python\n\n  def pytest_configure(config):\n    metadata = config.pluginmanager.getplugin(\"metadata\")\n    if metadata:\n        from pytest_metadata.plugin import metadata_key\n        config.stash[metadata_key]['foo'] = 'bar'\n\nPlugin integrations\n-------------------\n\nHere's a handy list of plugins that either read or contribute to the metadata:\n\n* `pytest-base-url \u003chttps://pypi.python.org/pypi/pytest-base-url/\u003e`_ - Adds the\n  base URL to the metadata.\n* `pytest-html \u003chttps://pypi.python.org/pypi/pytest-html/\u003e`_ - Displays the\n  metadata at the start of each report.\n* `pytest-reporter-html1 \u003chttps://pypi.org/project/pytest-reporter-html1/\u003e`_ -\n  Presents metadata as part of the report.\n* `pytest-selenium \u003chttps://pypi.python.org/pypi/pytest-selenium/\u003e`_ - Adds the\n  driver, capabilities, and remote server to the metadata.\n\nResources\n---------\n\n- `Release Notes \u003chttp://github.com/davehunt/pytest-metadata/blob/master/CHANGES.rst\u003e`_\n- `Issue Tracker \u003chttp://github.com/davehunt/pytest-metadata/issues\u003e`_\n- `Code \u003chttp://github.com/davehunt/pytest-metadata/\u003e`_\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpytest-dev%2Fpytest-metadata","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpytest-dev%2Fpytest-metadata","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpytest-dev%2Fpytest-metadata/lists"}