Add pytest_plugins and pytestmark special variables
This commit is contained in:
parent
443888248a
commit
3979f9ba3a
|
@ -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`_.
|
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
|
.. _`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
|
Requiring/Loading plugins in a test module or conftest file
|
||||||
-----------------------------------------------------------
|
-----------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,9 @@ pytest.warns
|
||||||
.. autofunction:: pytest.warns(expected_warning: Exception, [match])
|
.. autofunction:: pytest.warns(expected_warning: Exception, [match])
|
||||||
:with:
|
:with:
|
||||||
|
|
||||||
|
|
||||||
|
.. _`marks ref`:
|
||||||
|
|
||||||
Marks
|
Marks
|
||||||
-----
|
-----
|
||||||
|
|
||||||
|
@ -725,3 +728,47 @@ _Result
|
||||||
|
|
||||||
.. autoclass:: pluggy._Result
|
.. autoclass:: pluggy._Result
|
||||||
:members:
|
: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 <marks ref>` 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue