diff --git a/_pytest/doctest.py b/_pytest/doctest.py index aaebab78e..e447b8faf 100644 --- a/_pytest/doctest.py +++ b/_pytest/doctest.py @@ -1,6 +1,7 @@ """ discover and run doctests in modules and test files.""" import pytest, py +from _pytest.python import FixtureRequest, FuncFixtureInfo from py._code.code import TerminalRepr, ReprFileLocation def pytest_addoption(parser): @@ -70,9 +71,15 @@ class DoctestItem(pytest.Item): class DoctestTextfile(DoctestItem, pytest.File): def runtest(self): doctest = py.std.doctest + # satisfy `FixtureRequest` constructor... + self.funcargs = {} + self._fixtureinfo = FuncFixtureInfo((), [], {}) + fixture_request = FixtureRequest(self) failed, tot = doctest.testfile( str(self.fspath), module_relative=False, optionflags=doctest.ELLIPSIS, + extraglobs=dict(fixture_request=fixture_request, + get_fixture=fixture_request.getfuncargvalue), raise_on_error=True, verbose=0) class DoctestModule(DoctestItem, pytest.File):