Merge pull request #6039 from blueyed/test_doctest_id
doctest: unset RUNNER_CLASS in pytest_unconfigure
This commit is contained in:
commit
db9e248b2e
|
@ -0,0 +1,3 @@
|
||||||
|
The ``PytestDoctestRunner`` is properly invalidated when unconfiguring the doctest plugin.
|
||||||
|
|
||||||
|
This is important when used with ``pytester``'s ``runpytest_inprocess``.
|
|
@ -86,6 +86,12 @@ def pytest_addoption(parser):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def pytest_unconfigure():
|
||||||
|
global RUNNER_CLASS
|
||||||
|
|
||||||
|
RUNNER_CLASS = None
|
||||||
|
|
||||||
|
|
||||||
def pytest_collect_file(path, parent):
|
def pytest_collect_file(path, parent):
|
||||||
config = parent.config
|
config = parent.config
|
||||||
if path.ext == ".py":
|
if path.ext == ".py":
|
||||||
|
|
|
@ -859,16 +859,21 @@ class TestInvocationVariants:
|
||||||
4
|
4
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
result = testdir.runpytest("-rf")
|
testid = "test_doctest_id.txt::test_doctest_id.txt"
|
||||||
lines = result.stdout.str().splitlines()
|
expected_lines = [
|
||||||
for line in lines:
|
"*= FAILURES =*",
|
||||||
if line.startswith(("FAIL ", "FAILED ")):
|
"*_ ?doctest? test_doctest_id.txt _*",
|
||||||
_fail, _sep, testid = line.partition(" ")
|
"FAILED test_doctest_id.txt::test_doctest_id.txt",
|
||||||
break
|
"*= 1 failed in*",
|
||||||
result = testdir.runpytest(testid, "-rf")
|
]
|
||||||
result.stdout.fnmatch_lines(
|
result = testdir.runpytest(testid, "-rf", "--tb=short")
|
||||||
["FAILED test_doctest_id.txt::test_doctest_id.txt", "*1 failed*"]
|
result.stdout.fnmatch_lines(expected_lines)
|
||||||
)
|
|
||||||
|
# Ensure that re-running it will still handle it as
|
||||||
|
# doctest.DocTestFailure, which was not the case before when
|
||||||
|
# re-importing doctest, but not creating a new RUNNER_CLASS.
|
||||||
|
result = testdir.runpytest(testid, "-rf", "--tb=short")
|
||||||
|
result.stdout.fnmatch_lines(expected_lines)
|
||||||
|
|
||||||
def test_core_backward_compatibility(self):
|
def test_core_backward_compatibility(self):
|
||||||
"""Test backward compatibility for get_plugin_manager function. See #787."""
|
"""Test backward compatibility for get_plugin_manager function. See #787."""
|
||||||
|
|
Loading…
Reference in New Issue