Closed
Description
It seems like setup_module
is not being run in 8.0.1 when using --doctest-modules
. This works fine with 8.0.0.
This was seen in scikit-learn/scikit-learn#28461.
To reproduce:
# test.py
CONSTANT = 0
def setup_module():
global CONSTANT
CONSTANT = 1
def test():
assert CONSTANT == 1
pytest --doctest-modules test.py
Expected output: no failures
Actual output: failure
❯ pytest --doctest-modules test.py
======================================== test session starts ========================================
platform linux -- Python 3.12.2, pytest-8.0.1, pluggy-1.4.0
rootdir: /tmp/test
collected 1 item
test.py F [100%]
============================================= FAILURES ==============================================
_______________________________________________ test ________________________________________________
def test():
> assert CONSTANT == 1
E assert 0 == 1
test.py:9: AssertionError
====================================== short test summary info ======================================
FAILED test.py::test - assert 0 == 1
========================================= 1 failed in 0.01s =========================================
❯ pip list
Package Version
---------- -------
iniconfig 2.0.0
packaging 23.2
pip 24.0
pluggy 1.4.0
pytest 8.0.1
setuptools 69.1.0
wheel 0.42.0