summaryrefslogtreecommitdiff
path: root/odoo/service
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/service
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/service')
-rw-r--r--odoo/service/server.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/odoo/service/server.py b/odoo/service/server.py
index aceedc42d60..9ca6212e0ce 100644
--- a/odoo/service/server.py
+++ b/odoo/service/server.py
@@ -20,6 +20,7 @@ import unittest
import psutil
import werkzeug.serving
from werkzeug.debug import DebuggedApplication
+from odoo.tests.common import OdooSuite
if os.name == 'posix':
# Unix only for workers
@@ -1130,7 +1131,7 @@ def load_test_file_py(registry, test_file):
for mod_mod in get_test_modules(mod):
mod_path, _ = os.path.splitext(getattr(mod_mod, '__file__', ''))
if test_path == mod_path:
- suite = unittest.TestSuite()
+ suite = OdooSuite()
for t in unittest.TestLoader().loadTestsFromModule(mod_mod):
suite.addTest(t)
_logger.log(logging.INFO, 'running tests %s.', mod_mod.__name__)