Skip to content

Commit

Permalink
[IMP] base: Make assertQueryCount conditional on env vars.
Browse files Browse the repository at this point in the history
If the TEST_NO_FAIL_QUERY_COUNT env var is set, log a warning
instead of failing the build.
  • Loading branch information
amh-mw committed Apr 4, 2024
1 parent cf5a343 commit 13b01ed
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions odoo/tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 13b01ed

Please sign in to comment.