From f3ec4b634a75e22eac26cb03754a3d640ce4f1be Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Mon, 30 May 2022 09:05:45 +0000 Subject: [PATCH] [IMP] tests: enable warnings even when retrying tests When retrying a test, if a deprecation warning has been emitted the first time, it will not be re-emitted the second time, and will therefore not be shown in logs. Use warnings.catch_warnings() to reset the "emission counter" of the warnings. Part-of: odoo/odoo#92411 --- odoo/tests/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 94662d03d33..b9552b50ca8 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -360,7 +360,9 @@ class BaseCase(unittest.TestCase, metaclass=MetaCase): if retry: _logger.runbot(f'Retrying a failed test: {self}') if retry < tests_run_count-1: - with result.soft_fail(), lower_logging(25, logging.INFO) as quiet_log: + with warnings.catch_warnings(), \ + result.soft_fail(), \ + lower_logging(25, logging.INFO) as quiet_log: super().run(result) failure = result.had_failure or quiet_log.had_error_log else: # last try