Open pytestbot opened 9 years ago
:+1:
Unfortunately this is currently by design of setupstate
This has tripped me up before as well, but it shouldn't block 3.0.
I was curious. It's still a thing with the current code:
(pytest) √ 2024-pytest-sprint/reproducers %
cat test_657.py
def teardown_module(module):
assert False
def test_stuff():
pass
def test_things():
pass
(pytest) √ 2024-pytest-sprint/reproducers %
pytest test_657.py
================================================= test session starts ==================================================
platform darwin -- Python 3.11.9, pytest-8.3.0.dev105+g5037f8d11, pluggy-1.5.0
rootdir: /Users/ob/Library/CloudStorage/Dropbox/projects/2024-pytest-sprint/reproducers
collected 2 items
test_657.py ..E [100%]
======================================================== ERRORS ========================================================
___________________________________________ ERROR at teardown of test_things ___________________________________________
module = <module 'test_657' from '/Users/ob/Library/CloudStorage/Dropbox/projects/2024-pytest-sprint/reproducers/test_657.py'>
def teardown_module(module):
> assert False
E assert False
test_657.py:2: AssertionError
=============================================== short test summary info ================================================
ERROR test_657.py::test_things - assert False
============================================== 2 passed, 1 error in 0.02s ==============================================
This isn't specific to teardown_module
, it also happens with fixtures (see #12734). From what I could gather, the breaking changes proposed in #895 would fix this?
UPDATE 2024-17-06: this bug is still alive and kicking
Originally reported by: David MacIver (BitBucket: davidmaciver, GitHub: davidmaciver)
Consider a test suite like the following:
The result is:
In particular the "ERROR at teardown of test_things" bit is weird. It's not a big deal, but it would be better if this didn't get attached to the test which just happens to have run last but was instead marked as belonging to the module.