From 3979f9ba3a47d3c7a6fd6579438a257d6feceb58 Mon Sep 17 00:00:00 2001 From: Bruno Oliveira Date: Thu, 1 Mar 2018 18:20:55 -0300 Subject: [PATCH] Add pytest_plugins and pytestmark special variables --- doc/en/plugins.rst | 3 ++- doc/en/reference.rst | 47 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/doc/en/plugins.rst b/doc/en/plugins.rst index 276b394d0..4089b9b28 100644 --- a/doc/en/plugins.rst +++ b/doc/en/plugins.rst @@ -61,10 +61,11 @@ status against different pytest and Python versions, please visit You may also discover more plugins through a `pytest- pypi.python.org search`_. -.. _`available installable plugins`: .. _`pytest- pypi.python.org search`: http://pypi.python.org/pypi?%3Aaction=search&term=pytest-&submit=search +.. _`available installable plugins`: + Requiring/Loading plugins in a test module or conftest file ----------------------------------------------------------- diff --git a/doc/en/reference.rst b/doc/en/reference.rst index 415c618ba..8cf95a818 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -84,6 +84,9 @@ pytest.warns .. autofunction:: pytest.warns(expected_warning: Exception, [match]) :with: + +.. _`marks ref`: + Marks ----- @@ -725,3 +728,47 @@ _Result .. autoclass:: pluggy._Result :members: + +Special Variables +----------------- + +pytest treats some global variables in a special manner when defined in a test module. + + +pytest_plugins +~~~~~~~~~~~~~~ + +**Tutorial**: :ref:`available installable plugins` + +Can be declared at the **global** level in *test modules* and *conftest.py files* to register additional plugins. +Can be either a ``str`` or ``Sequence[str]``. + +.. code-block:: python + + pytest_plugins = "myapp.testsupport.myplugin" + +.. code-block:: python + + pytest_plugins = ("myapp.testsupport.tools", "myapp.testsupport.regression") + + +pytest_mark +~~~~~~~~~~~ + +**Tutorial**: :ref:`scoped-marking` + +Can be declared at the **global** level in *test modules* to apply one or more :ref:`marks ` to all +test functions and methods. Can be either a single mark or a sequence of marks. + +.. code-block:: python + + import pytest + pytestmark = pytest.mark.webtest + + +.. code-block:: python + + import pytest + pytestmark = (pytest.mark.integration, pytest.mark.slow) + +