From 73c2563b7ea7d89128439426f71897695a2d532a Mon Sep 17 00:00:00 2001 From: Raphael Collet Date: Tue, 3 Dec 2019 07:58:28 +0000 Subject: [PATCH] [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. --- odoo/tests/common.py | 4 ++++ 1 file changed, 4 insertions(+) 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()