From 9e41603743b751cb0724249022d3d834eec0a437 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 2 Dec 2021 13:30:09 +0000 Subject: [PATCH] [FIX] tests: fix race condition when spawning chrome MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When Chrome is spawned, the `DevToolsActivePort`file is awaited to read the port. Sometimes the file is read but is still empty, resulting in a ValueError when trying to cast into integer. This happens when Chrome did not have time yet to write into file. With this commit, we expect the file to contain at least 5 bytes which is enough to contain the max port number. closes odoo/odoo#80791 X-original-commit: aab53fbb4e02461e0f23cf202d393e30a73fbc92 Signed-off-by: Xavier Dollé (xdo) Signed-off-by: Christophe Monniez (moc) --- odoo/tests/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index d45c55d8546..c08714cf449 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -913,7 +913,7 @@ class ChromeBrowser: port_file = pathlib.Path(self.user_data_dir, 'DevToolsActivePort') for _ in range(100): time.sleep(0.1) - if port_file.is_file(): + if port_file.is_file() and port_file.stat().st_size > 5: with port_file.open('r', encoding='utf-8') as f: self.devtools_port = int(f.readline()) break