Merge pull request #12013 from bluetech/doctest-test
testing: add a regression test for `setup_module` + `--doctest-modules`
This commit is contained in:
commit
8a410d0ba6
|
@ -0,0 +1 @@
|
|||
Fixed a regression in 8.0.1 whereby ``setup_module`` xunit-style fixtures are not executed when ``--doctest-modules`` is passed.
|
|
@ -878,6 +878,25 @@ class TestDoctests:
|
|||
result = pytester.runpytest(p, "--doctest-modules")
|
||||
result.stdout.fnmatch_lines(["*collected 1 item*"])
|
||||
|
||||
def test_setup_module(self, pytester: Pytester) -> None:
|
||||
"""Regression test for #12011 - setup_module not executed when running
|
||||
with `--doctest-modules`."""
|
||||
pytester.makepyfile(
|
||||
"""
|
||||
CONSTANT = 0
|
||||
|
||||
def setup_module():
|
||||
global CONSTANT
|
||||
CONSTANT = 1
|
||||
|
||||
def test():
|
||||
assert CONSTANT == 1
|
||||
"""
|
||||
)
|
||||
result = pytester.runpytest("--doctest-modules")
|
||||
assert result.ret == 0
|
||||
result.assert_outcomes(passed=1)
|
||||
|
||||
|
||||
class TestLiterals:
|
||||
@pytest.mark.parametrize("config_mode", ["ini", "comment"])
|
||||
|
|
Loading…
Reference in New Issue