Merge pull request #12013 from bluetech/doctest-test

testing: add a regression test for `setup_module` + `--doctest-modules`
This commit is contained in:
Ran Benita 2024-02-20 22:22:01 +02:00 committed by GitHub
commit 8a410d0ba6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 0 deletions

View 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.

View File

@ -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"])