summaryrefslogtreecommitdiff
path: root/odoo/modules/module.py
diff options
context:
space:
mode:
authorXavier-Do <xdo@odoo.com>2019-07-29 14:59:51 +0000
committerXavier-Do <xdo@odoo.com>2019-07-30 09:15:30 +0000
commit22930162727a22db9cb6cb300eaa0852e3f5085a (patch)
tree9efccdd99e011610687d0b5ee9b1fa70aa8177a6 /odoo/modules/module.py
parent4f33ae16154b9c5203c231f8dbe9425696e3291d (diff)
[FIX] core: log error on addSubTest
Since #34996, in some case, the error detail was not logged keeping only the final summary "x errors, x failures" when running TestSuite. Making fail test test_cache_invalidation for instance won't show a detailed message when breaking test_01_project_tour will. This issue occurs when using subtest, like with assertQueryCount, @users decorator, test_all_l10n, and test_youtube_urls. Since Testresult addSubTest append directly to error and failures instead of calling addError and addFailure, we need to ovewrite addSubtest too. closes odoo/odoo#35270 Signed-off-by: Denis Ledoux <beledouxdenis@users.noreply.github.com>
Diffstat (limited to 'odoo/modules/module.py')
-rw-r--r--odoo/modules/module.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/odoo/modules/module.py b/odoo/modules/module.py
index f99c25ea11d..5dd452d17d9 100644
--- a/odoo/modules/module.py
+++ b/odoo/modules/module.py
@@ -511,6 +511,17 @@ class OdooTestResult(unittest.result.TestResult):
super().addFailure(test, err)
self.logError("FAIL", test, err)
+ def addSubTest(self, test, subtest, err):
+ # since addSubTest is not making a call to addFailure or addError we need to manage it too
+ # https://github.com/python/cpython/blob/3.7/Lib/unittest/result.py#L136
+ if err is not None:
+ if issubclass(err[0], test.failureException):
+ flavour = "FAIL"
+ else:
+ flavour = "ERROR"
+ self.logError(flavour, subtest, err)
+ super().addSubTest(test, subtest, err)
+
def addSkip(self, test, reason):
super().addSkip(test, reason)
self.log(logging.INFO, 'skipped %s', self.getDescription(test), test=test)