Repository navigation
Treat errors in pytest_unconfigure as internal errors - #15186
rafael-g-v wants to merge 3 commits into
Conversation
The try/except around _ensure_unconfigure() was nested under 'if initstate >= 2', so it only ran when the session had started. Some existing tests expected exit code 1 and the traceback in stderr for errors raised during config cleanup; they now expect INTERNAL_ERROR (3) and INTERNALERROR> lines in stdout. Also add a test for pytest.exit() called from pytest_unconfigure.
|
I updated 4 existing tests (in test_threadexception.py and test_unraisableexception.py) that expected the old behavior: exit code 1 and the traceback in stderr. With this change, errors raised during config cleanup are reported as an internal error (exit code 3) with INTERNALERROR> lines in stdout. Some of these tests have a TODO saying the outcome should be a test failure or error. Is exit code 3 acceptable here, or would you prefer a different handling for these cases? The Read the Docs failure seems unrelated to this PR: the only warning is "py:class reference target not found: pluggy._compat.DistFacade", from the PluginManager.list_plugin_distinfo docstring in the new pluggy 1.7.0 release. |
|
Hi @nicoddemus, sorry for the ping! When you have some time, could you take a look at this PR? I'd especially like to know if changing the expected exit code in the existing unraisable/thread exception tests is acceptable. Thanks! |
Closes #9808
Exceptions raised in
pytest_unconfigurehooks escapedwrap_sessionand made pytest exit with code 1 and a raw traceback. Now they are reported as an internal error (exit code 3), the same as exceptions inpytest_configure.config._ensure_unconfigure()with the same handling already usedfor
pytest_sessionfinish.testing/test_main.pyand a changelog entry.I'm a student; I used an AI assistant to help find the cause and write the change, and I reviewed and tested it myself. Any feedback is welcome!