BaseFileTest.tearDown() in test_logging unlinks the log files and then calls BaseTest.tearDown(), which removes the handler added by BaseTest.setUp().
If unlinking fails, BaseTest.tearDown() is not called, the handler is left on the root logger, and every following test fails in setUp() with "Unexpected handlers", hiding the original error.
The files registered by assertLogFile() are unlinked without checking that they still exist, so this happens if a test removes its own log file, for example by creating it in a temporary directory removed by a cleanup function.
No test does that now, so the bug is latent. I ran into it with an experimental change to the order in which cleanup functions are called.
Linked PRs
BaseFileTest.tearDown()in test_logging unlinks the log files and then callsBaseTest.tearDown(), which removes the handler added byBaseTest.setUp().If unlinking fails,
BaseTest.tearDown()is not called, the handler is left on the root logger, and every following test fails insetUp()with "Unexpected handlers", hiding the original error.The files registered by
assertLogFile()are unlinked without checking that they still exist, so this happens if a test removes its own log file, for example by creating it in a temporary directory removed by a cleanup function.No test does that now, so the bug is latent. I ran into it with an experimental change to the order in which cleanup functions are called.
Linked PRs