[New-bugs-announce] [issue43913] unittest module cleanup functions not run unless tearDownModule() is defined

Ryan Tarpine report at bugs.python.org
Thu Apr 22 13:30:03 EDT 2021


New submission from Ryan Tarpine <rtarpine at google.com>:

Functions registered with unittest.addModuleCleanup are not called unless the user defines tearDownModule in their test module.

This behavior is unexpected because functions registered with TestCase.addClassCleanup are called even the user doesn't define tearDownClass, and similarly with addCleanup/tearDown.

The implementing code is basically the same for all 3 cases, the difference is that unittest.TestCase itself defines tearDown and tearDownClass; so even though doClassCleanups is only called if tearDownClass is defined, in practice it always is.

doModuleCleanups should be called even if tearDownModule is not defined.

----------
components: Library (Lib)
messages: 391619
nosy: rtarpine
priority: normal
severity: normal
status: open
title: unittest module cleanup functions not run unless tearDownModule() is defined
type: behavior
versions: Python 3.8

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43913>
_______________________________________


More information about the New-bugs-announce mailing list