testing: add a regression test for setup_module + --doctest-modules
Refs #12011 (only fails on 8.0.1, not main).
This commit is contained in:
1
changelog/12011.bugfix.rst
Normal file
1
changelog/12011.bugfix.rst
Normal file
@@ -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"])
|
||||
|
||||
Reference in New Issue
Block a user