Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
TestCase class methodsaddClassCleanup() anddoClassCleanups() are similar to instance methodsaddCleanup() anddoCleanups().add*Cleanup() add a callback into a list, anddo*Cleanups() pop them from a list and call. The main difference is that the latter methods use a list stored as an instance attribute while the former use a list stored as a class attribute.
The problem is that the class attributeTestCase._class_cleanups is shared between allTestCase subclasses. It usually does not cause the problem, because tests in different test classes are run sequentially, but if you run a new test suite while running a test, and the outer test class useaddClassCleanup(), the callback registered for the outer test class will be called when cleaning up the inner test class. It can happen when you testunittest itself. It really happened, and was unnoticed only because the outer class did not useaddClassCleanup().
Linked PRs
Metadata
Metadata
Assignees
Labels
Projects
Status