From 13b01edc94d43cb7b93ad60033dc3083f13c8f7d Mon Sep 17 00:00:00 2001 From: Adam Heinz Date: Wed, 3 Apr 2024 13:34:00 -0400 Subject: [PATCH] [IMP] base: Make assertQueryCount conditional on env vars. If the TEST_NO_FAIL_QUERY_COUNT env var is set, log a warning instead of failing the build. --- odoo/tests/common.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index 3dd053f2b22fa..395d908165724 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -519,9 +519,12 @@ def assertQueryCount(self, default=0, flush=True, **counters): filename = filename.rsplit("/odoo/addons/", 1)[1] if count > expected: msg = "Query count more than expected for user %s: %d > %d in %s at %s:%s" - # add a subtest in order to continue the test_method in case of failures - with self.subTest(): - self.fail(msg % (login, count, expected, funcname, filename, linenum)) + if os.environ.get('TEST_NO_FAIL_QUERY_COUNT'): + _logger.warning(msg, login, count, expected, funcname, filename, linenum) + else: + # add a subtest in order to continue the test_method in case of failures + with self.subTest(): + self.fail(msg % (login, count, expected, funcname, filename, linenum)) else: logger = logging.getLogger(type(self).__module__) msg = "Query count less than expected for user %s: %d < %d in %s at %s:%s"