summaryrefslogtreecommitdiff
path: root/odoo/modules/module.py
diff options
context:
space:
mode:
authorAdrian Torres <adt@odoo.com>2019-11-04 08:49:47 +0000
committerAdrian Torres <adt@odoo.com>2019-11-06 14:07:04 +0000
commitec587297eb9e245db6fe2b6ca1953a5f9bbda27e (patch)
tree9895ae01c6aee63f422623e7c40fa2bc138fd214 /odoo/modules/module.py
parentbb716ce6acc48693175e2c11ce42ef4526564001 (diff)
[IMP] tests: partially backport classCleanups from CPython 3.8
This commit partially backports bpo-24412, which allows the definition of class cleanups (addClassCleanup) and module cleanups (omitted), similar to instance cleanups (addCleanup). This is useful for tests that override unittest's setUpClass and could crash during its execution: If this happens, it is possible that a bunch of crap is left in the database or even worse, the cursor becomes completely fucked; Thanks to the addClassCleanup, we can undo the damage done by the setUpClass. Another benefit is that it is called unconditionally after tearDownClass is called, so it can also be called as a replacement and/or safer tearDownClass.
Diffstat (limited to 'odoo/modules/module.py')
-rw-r--r--odoo/modules/module.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/odoo/modules/module.py b/odoo/modules/module.py
index 8d0dd5a7091..851395ba280 100644
--- a/odoo/modules/module.py
+++ b/odoo/modules/module.py
@@ -492,7 +492,8 @@ def run_unit_tests(module_name, position='at_install'):
:rtype: bool
"""
global current_test
- from odoo.tests.common import TagsSelector # Avoid import loop
+ # avoid dependency hell
+ from odoo.tests.common import TagsSelector, OdooSuite
current_test = module_name
mods = get_test_modules(module_name)
threading.currentThread().testing = True
@@ -501,7 +502,7 @@ def run_unit_tests(module_name, position='at_install'):
r = True
for m in mods:
tests = unwrap_suite(unittest.TestLoader().loadTestsFromModule(m))
- suite = unittest.TestSuite(t for t in tests if position_tag.check(t) and config_tags.check(t))
+ suite = OdooSuite(t for t in tests if position_tag.check(t) and config_tags.check(t))
if suite.countTestCases():
t0 = time.time()