METADATA 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. Metadata-Version: 2.1
  2. Name: pytest-metadata
  3. Version: 1.7.0
  4. Summary: pytest plugin for test session metadata
  5. Home-page: https://github.com/pytest-dev/pytest-metadata
  6. Author: Dave Hunt
  7. Author-email: dhunt@mozilla.com
  8. License: Mozilla Public License 2.0 (MPL 2.0)
  9. Keywords: py.test pytest metadata
  10. Platform: UNKNOWN
  11. Classifier: Development Status :: 5 - Production/Stable
  12. Classifier: Framework :: Pytest
  13. Classifier: Intended Audience :: Developers
  14. Classifier: License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)
  15. Classifier: Operating System :: POSIX
  16. Classifier: Operating System :: Microsoft :: Windows
  17. Classifier: Operating System :: MacOS :: MacOS X
  18. Classifier: Topic :: Software Development :: Quality Assurance
  19. Classifier: Topic :: Software Development :: Testing
  20. Classifier: Topic :: Utilities
  21. Classifier: Programming Language :: Python
  22. Classifier: Programming Language :: Python :: 2.7
  23. Classifier: Programming Language :: Python :: 3.6
  24. Requires-Dist: pytest (>=2.9.0)
  25. pytest-metadata
  26. ===============
  27. pytest-metadata is a plugin for `pytest <http://pytest.org>`_ that provides
  28. access to test session metadata.
  29. .. image:: https://img.shields.io/badge/license-MPL%202.0-blue.svg
  30. :target: https://github.com/pytest-dev/pytest-metadata/blob/master/LICENSE
  31. :alt: License
  32. .. image:: https://img.shields.io/pypi/v/pytest-metadata.svg
  33. :target: https://pypi.python.org/pypi/pytest-metadata/
  34. :alt: PyPI
  35. .. image:: https://img.shields.io/travis/pytest-dev/pytest-metadata.svg
  36. :target: https://travis-ci.org/pytest-dev/pytest-metadata/
  37. :alt: Travis
  38. .. image:: https://img.shields.io/github/issues-raw/pytest-dev/pytest-metadata.svg
  39. :target: https://github.com/pytest-dev/pytest-metadata/issues
  40. :alt: Issues
  41. .. image:: https://img.shields.io/requires/github/pytest-dev/pytest-metadata.svg
  42. :target: https://requires.io/github/pytest-dev/pytest-metadata/requirements/?branch=master
  43. :alt: Requirements
  44. Requirements
  45. ------------
  46. You will need the following prerequisites in order to use pytest-metadata:
  47. - Python 2.7, 3.6, PyPy, or PyPy3
  48. Installation
  49. ------------
  50. To install pytest-metadata:
  51. .. code-block:: bash
  52. $ pip install pytest-metadata
  53. Available metadata
  54. ------------------
  55. The following metadata is gathered by this plugin:
  56. ======== =============== ===================================
  57. Key Description Example
  58. ======== =============== ===================================
  59. Python Python version 3.6.4
  60. Platform Platform Darwin-17.4.0-x86_64-i386-64bit
  61. Packages pytest packages {'py': '1.5.2', 'pytest': '3.4.1'}
  62. Plugins pytest plugins {'metadata': '1.6.0'}
  63. ======== =============== ===================================
  64. Additional metadata
  65. -------------------
  66. You can provide your own metadata (key, value pair) by specifying ``--metadata`` on the commandline::
  67. pytest --metadata foo bar
  68. Note: You can provide multiple sets of ``--metadata``::
  69. pytest --metadata foo bar --metadata baz zoo
  70. Continuous integration
  71. ----------------------
  72. When run in a continuous integration environment, additional metadata is added
  73. from environment variables. Below is a list of the supported continuous
  74. integration providers, along with links to the environment variables that are
  75. added to metadata if they're present.
  76. * `AppVeyor <https://www.appveyor.com/docs/environment-variables/>`_
  77. * `CircleCI <https://circleci.com/docs/1.0/environment-variables/>`_
  78. * `GitLab CI <http://docs.gitlab.com/ce/ci/variables/README.html>`_
  79. * `Jenkins <https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project#Buildingasoftwareproject-JenkinsSetEnvironmentVariables>`_
  80. * `TaskCluster <https://docs.taskcluster.net/reference/workers/docker-worker/environment>`_
  81. * `Travis CI <https://docs.travis-ci.com/user/environment-variables/>`_
  82. Note that if you're using `Tox <http://tox.readthedocs.io/>`_ to run your tests
  83. then you will need to `pass down any additional environment variables <http://tox.readthedocs.io/en/latest/example/basic.html#passing-down-environment-variables>`_
  84. for these to be picked up.
  85. Viewing metadata
  86. ----------------
  87. If you pass ``--verbose`` on the command line when running your tests, then the
  88. metadata will be displayed in the terminal report header::
  89. pytest --verbose
  90. ============================ test session starts ============================
  91. platform darwin -- Python 3.6.4, pytest-3.4.1, py-1.5.2, pluggy-0.6.0 -- /usr/bin/python
  92. cachedir: .pytest_cache
  93. 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'}}
  94. plugins: metadata-1.6.0
  95. Accessing metadata
  96. ------------------
  97. To add/modify/delete metadata at the end of metadata collection, you can use the `pytest_metadata` hook:
  98. .. code-block:: python
  99. import pytest
  100. @pytest.mark.optionalhook
  101. def pytest_metadata(metadata):
  102. for key in metadata.keys():
  103. if "password" in key.lower():
  104. del metadata[key]
  105. To access the metadata from a test or fixture, you can use the `metadata`
  106. fixture:
  107. .. code-block:: python
  108. def test_metadata(metadata):
  109. assert 'metadata' in metadata['Plugins']
  110. To access the metadata from a plugin, you can use the `_metadata` attribute of
  111. the `config` object. This can be used to read/add/modify the metadata:
  112. .. code-block:: python
  113. def pytest_configure(config):
  114. if hasattr(config, '_metadata'):
  115. config._metadata['foo'] = 'bar'
  116. Plugin integrations
  117. -------------------
  118. Here's a handy list of plugins that either read or contribute to the metadata:
  119. * `pytest-base-url <https://pypi.python.org/pypi/pytest-base-url/>`_ - Adds the
  120. base URL to the metadata.
  121. * `pytest-html <https://pypi.python.org/pypi/pytest-html/>`_ - Displays the
  122. metadata at the start of each report.
  123. * `pytest-selenium <https://pypi.python.org/pypi/pytest-selenium/>`_ - Adds the
  124. driver, capabilities, and remote server to the metadata.
  125. Resources
  126. ---------
  127. - `Release Notes <http://github.com/davehunt/pytest-metadata/blob/master/CHANGES.rst>`_
  128. - `Issue Tracker <http://github.com/davehunt/pytest-metadata/issues>`_
  129. - `Code <http://github.com/davehunt/pytest-metadata/>`_