File tree 2 files changed +20
-0
lines changed 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change
1
+ Fixed a regression in 8.0.1 whereby ``setup_module `` xunit-style fixtures are not executed when ``--doctest-modules `` is passed.
Original file line number Diff line number Diff line change @@ -878,6 +878,25 @@ def test_foo():
878
878
result = pytester .runpytest (p , "--doctest-modules" )
879
879
result .stdout .fnmatch_lines (["*collected 1 item*" ])
880
880
881
+ def test_setup_module (self , pytester : Pytester ) -> None :
882
+ """Regression test for #12011 - setup_module not executed when running
883
+ with `--doctest-modules`."""
884
+ pytester .makepyfile (
885
+ """
886
+ CONSTANT = 0
887
+
888
+ def setup_module():
889
+ global CONSTANT
890
+ CONSTANT = 1
891
+
892
+ def test():
893
+ assert CONSTANT == 1
894
+ """
895
+ )
896
+ result = pytester .runpytest ("--doctest-modules" )
897
+ assert result .ret == 0
898
+ result .assert_outcomes (passed = 1 )
899
+
881
900
882
901
class TestLiterals :
883
902
@pytest .mark .parametrize ("config_mode" , ["ini" , "comment" ])
You can’t perform that action at this time.
0 commit comments