summaryrefslogtreecommitdiff
path: root/odoo/modules
diff options
context:
space:
mode:
authorXavier-Do <xdo@odoo.com>2019-08-27 14:47:47 +0000
committerXavier-Do <xdo@odoo.com>2019-08-27 15:01:38 +0000
commit7c219995379c64aa73140b31976ab464a148aafb (patch)
treed4b315b310443deb3c29d7dddcdc4f2d39161709 /odoo/modules
parent24c92d8b950ec6ef457e4dc7be7c3a59edf607dd (diff)
[FIX] core: Correctly handle log_level in odooTestResult
Before this commit --log-level had no impact on test logs. We need to check logger "isEnabledFor" before makeRecord since logger will make this check in error,warn,log... dedicated function before making call to _log. We also need to use modules.py runner instead of unittest logger in OdooTestRunner (test will allways be a suite there) closes odoo/odoo#36142 Signed-off-by: Romain Libert (rli) <rli@odoo.com>
Diffstat (limited to 'odoo/modules')
-rw-r--r--odoo/modules/module.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/odoo/modules/module.py b/odoo/modules/module.py
index 61ebadeeb95..13c1600985e 100644
--- a/odoo/modules/module.py
+++ b/odoo/modules/module.py
@@ -489,8 +489,9 @@ class OdooTestResult(unittest.result.TestResult):
# using logger.log makes it difficult to spot-replace findCaller in
# order to provide useful location information (the problematic spot
# inside the test function), so use lower-level functions instead
- record = logger.makeRecord(logger.name, level, fn, lno, msg, args, exc_info, func, extra, sinfo)
- logger.handle(record)
+ if logger.isEnabledFor(level):
+ record = logger.makeRecord(logger.name, level, fn, lno, msg, args, exc_info, func, extra, sinfo)
+ logger.handle(record)
def getDescription(self, test):
if isinstance(test, unittest.TestCase):
@@ -573,10 +574,8 @@ class OdooTestRunner(object):
start_time = time.perf_counter()
test(result)
time_taken = time.perf_counter() - start_time
-
- logger = logging.getLogger(test.__module__)
run = result.testsRun
- logger.info("Ran %d test%s in %.3fs", run, run != 1 and "s" or "", time_taken)
+ _logger.info("Ran %d test%s in %.3fs", run, run != 1 and "s" or "", time_taken)
return result
current_test = None