New submission from Ryan Tarpine <rtarp...@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 <rep...@bugs.python.org>
<https://bugs.python.org/issue43913>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to