Confusing log for teardown
See original GitHub issueDescription
For test files where the last test is skipped, if module level teardown incurs exception, the exception would still be attributed to the skipped test.
Example
- Save the following snippet as test.py
import pytest
def teardown_module():
print('executed teardown')
raise RuntimeError()
def test_test():
print('executed test')
pass
@pytest.mark.skip(reason='something')
def test_skipped():
print('executed skipped')
pass
-
run
pytest -v test.py
-
output
% pytest -v test.py
==================================================================== test session starts =====================================================================
platform darwin -- Python 3.7.7, pytest-5.4.1, py-1.8.0, pluggy-0.13.1 -- /usr/local/opt/python/bin/python3.7
cachedir: xx
rootdir: xx
plugins: env-0.6.2, xdist-1.31.0, forked-1.1.3, cov-2.8.1
collected 2 items
test.py::test_test PASSED [ 50%]
test.py::test_skipped SKIPPED [100%]
test.py::test_skipped ERROR [100%]
=========================================================================== ERRORS ===========================================================================
_____________________________________________________________ ERROR at teardown of test_skipped ______________________________________________________________
def teardown_module():
print('executed teardown')
> raise RuntimeError()
E RuntimeError
test.py:5: RuntimeError
------------------------------------------------------------------ Captured stdout teardown ------------------------------------------------------------------
executed teardown
================================================================== short test summary info ===================================================================
ERROR test.py::test_skipped - RuntimeError
=========================================================== 1 passed, 1 skipped, 1 error in 0.21s ============================================================
Env
OSX w/ pytest 5.4.1
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Robotframework: behavior when teardown fails - Stack Overflow
Sometimes the test fails in tear down is an important issue, for example, the clean up is not completed and it causes other...
Read more >I think I can play Teardown after this... - YouTube
It turns out the treadmill never left Teardown...Leave a like and Subscribe if you enjoyed! Thanks =)Subscribe!
Read more >UnitySetUp and UnityTearDown | Test Framework | 1.1.33
Log ("This runs inside playmode"); } [UnityTearDown] public IEnumerator TearDown() { yield return new ExitPlayMode(); } } ...
Read more >Teardown: Recon Sentinel - Hackaday
The LCD showed an error message about connectivity, but I was able to log in over SSH with no issue at that point....
Read more >UnitySetUp and UnityTearDown | Test ... - Unity - Manual
Log ("This runs inside playmode"); } [UnityTearDown] public IEnumerator TearDown() { yield return new ExitPlayMode(); } } ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I think this is working as intended - while it might be unintuitive, changing where we report teardown errors depending on skipped status (which can be decided within the test, and potentially nondeterministically!) is likely to cause worse problems.
setting this as duplicate of #895