pytest-dev / pytest-dev/pytest
Errors in teardown_module erroneously attached to last executed test
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 14.5k
- Forks
- 3.4k
- Avg merge
- 2d 9h
- Merged PRs (30d)
- 35
Description
UPDATE 2024-17-06: this bug is still alive and kicking
Originally reported by: David MacIver (BitBucket: david_maciver_, GitHub: david_maciver_)
Consider a test suite like the following:
#!python
def teardown_module(module):
assert False
def test_stuff():
pass
def test_things():
pass
The result is:
collected 2 items
test_module_teardown.py ..E
=================================================== ERRORS ===================================================
______________________________________ ERROR at teardown of test_things ______________________________________
Traceback (most recent call last):
File "/home/david/projects/hypothesis/test_module_teardown.py", line 2, in teardown_module
assert False
AssertionError: assert False
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the example in test_module_teardown.py, focusing on teardown_module and the reported “ERROR at teardown of test_things” association. Trace how module teardown errors are attached to the final test, then verify that the failure is reported as belonging to the module rather than the last executed test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- testing
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100