[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.
This commit is contained in:
Raphael Collet
2020-02-05 13:50:23 +00:00
parent e753bb1a85
commit 73c2563b7e
+4
View File
@@ -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()