summaryrefslogtreecommitdiff
path: root/odoo/tests
diff options
context:
space:
mode:
authorRaphael Collet <rco@odoo.com>2019-12-03 07:58:28 +0000
committerRaphael Collet <rco@odoo.com>2020-02-05 13:50:23 +0000
commit73c2563b7ea7d89128439426f71897695a2d532a (patch)
treec0d6afd60c9ebf4298b536c530c194d60326bc46 /odoo/tests
parente753bb1a85bac83b0e4dc536ae6d4992cbe4907f (diff)
[FIX] tests: add flush during warmup to get correct query counts
In order to count queries exactly, the warmup phase of a test method (decorator `@warmup`) must do the exact same operations as the normal phase.
Diffstat (limited to 'odoo/tests')
-rw-r--r--odoo/tests/common.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/odoo/tests/common.py b/odoo/tests/common.py
index 6dbc576b7be..87a7889e4ec 100644
--- a/odoo/tests/common.py
+++ b/odoo/tests/common.py
@@ -400,6 +400,10 @@ class BaseCase(TreeCase, MetaCase('DummyCase', (object,), {})):
msg = "Query count less than expected for user %s: %d < %d in %s at %s:%s"
logger.info(msg, login, count, expected, funcname, filename, linenum)
else:
+ # flush before and after during warmup, in order to reproduce the
+ # same operations, otherwise the caches might not be ready!
+ if flush:
+ self.env.user.flush()
yield
if flush:
self.env.user.flush()