From 426fc163bac0aa76fa231d1253e966dea8aca39d Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Fri, 14 Feb 2020 15:23:11 +0000 Subject: [PATCH] [FIX] tests: avoid confusing traceback at browser start During an HttpCase, when the Chrome browser starts, it may happens that the websocket is unreachable. In such a case, the stop method is called and tries to stop the browser gracefully by sending a `Browser.close` through the websocket ... which is not reachable. The result is a confusing traceback. With this commit, nothing is sent is the websocket is not available. Moreover, the `sigxcpu_handler` attribute is used in the stop method but not yet declared. Fixed by moving it before calling the _chrome_start method. X-original-commit: 0d156fd3bc114b40680ca5aa0456e0f21a5b8cff --- odoo/tests/common.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index c72832b4ad0..c68aaf0e515 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -644,6 +644,7 @@ class ChromeBrowser(): os.makedirs(self.screenshots_dir, exist_ok=True) self.window_size = window_size + self.sigxcpu_handler = None self._chrome_start() self._find_websocket() self._logger.info('Websocket url found: %s', self.ws_url) @@ -652,7 +653,6 @@ class ChromeBrowser(): self._websocket_send('Runtime.enable') self._logger.info('Chrome headless enable page notifications') self._websocket_send('Page.enable') - self.sigxcpu_handler = None if os.name == 'posix': self.sigxcpu_handler = signal.getsignal(signal.SIGXCPU) signal.signal(signal.SIGXCPU, self.signal_handler) @@ -811,6 +811,8 @@ class ChromeBrowser(): """ send chrome devtools protocol commands through websocket """ + if self.ws is None: + return sent_id = self.request_id payload = { 'method': method,