diff --git a/_pytest/doctest.py b/_pytest/doctest.py index f54f833ec..a7bb2598c 100644 --- a/_pytest/doctest.py +++ b/_pytest/doctest.py @@ -379,6 +379,6 @@ def _fix_spoof_python2(runner, encoding): @pytest.fixture(scope='session') def doctest_namespace(): """ - Inject names into the doctest namespace. + Fixture that returns a :py:class:`dict` that will be injected into the namespace of doctests. """ return dict() diff --git a/doc/en/doctest.rst b/doc/en/doctest.rst index 61fbe04d4..78255516a 100644 --- a/doc/en/doctest.rst +++ b/doc/en/doctest.rst @@ -116,6 +116,8 @@ itself:: 'Hello' +.. _`doctest_namespace`: + The 'doctest_namespace' fixture ------------------------------- diff --git a/doc/en/reference.rst b/doc/en/reference.rst index b10b3126c..91a26e31c 100644 --- a/doc/en/reference.rst +++ b/doc/en/reference.rst @@ -260,8 +260,6 @@ capsys .. currentmodule:: _pytest.capture .. autofunction:: capsys() - :no-auto-options: - :decorator: Returns an instance of :py:class:`CaptureFixture`. @@ -279,8 +277,6 @@ capsysbinary ~~~~~~~~~~~~ .. autofunction:: capsysbinary() - :no-auto-options: - :decorator: Returns an instance of :py:class:`CaptureFixture`. @@ -298,8 +294,6 @@ capfd ~~~~~~ .. autofunction:: capfd() - :no-auto-options: - :decorator: Returns an instance of :py:class:`CaptureFixture`. @@ -317,8 +311,6 @@ capfdbinary ~~~~~~~~~~~~ .. autofunction:: capfdbinary() - :no-auto-options: - :decorator: Returns an instance of :py:class:`CaptureFixture`. @@ -332,3 +324,17 @@ capfdbinary assert captured.out == b"hello\n" +doctest_namespace +~~~~~~~~~~~~~~~~~ + +.. autofunction:: _pytest.doctest.doctest_namespace() + + Usually this fixture is used in conjunction with another ``autouse`` fixture: + + .. code-block:: python + + @pytest.fixture(autouse=True) + def add_np(doctest_namespace): + doctest_namespace['np'] = numpy + + For more details: :ref:`doctest_namespace`.