From 49fb7a4682bf57165f1964a36dca477ff86e2ae7 Mon Sep 17 00:00:00 2001 From: Christophe Monniez Date: Thu, 16 Aug 2018 15:07:43 +0200 Subject: [PATCH] [FIX] tests: avoid traceback when websocket-client is not installed The account module needs to import Form from "tests.common" causing a traceback when websocket-client module is not installed. As this module is only required for the tests, there is no reason to add it to the "requirements.txt" file. With this commit, Odoo account can be installed even when websocket-client is not installed, in that case, the HttpCase tests that needs to run Chrome headless will be skipped with a warning. Closes: #26404 --- odoo/tests/common.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/odoo/tests/common.py b/odoo/tests/common.py index f843dd75fd9..1be24f83c5a 100644 --- a/odoo/tests/common.py +++ b/odoo/tests/common.py @@ -25,7 +25,6 @@ import tempfile import threading import time import unittest -import websocket import werkzeug.urls from contextlib import contextmanager from datetime import datetime, timedelta, date @@ -43,6 +42,13 @@ try: from itertools import zip_longest as izip_longest except ImportError: from itertools import izip_longest + +try: + import websocket +except ImportError: + # chrome headless tests will be skipped + websocket = None + try: from xmlrpc import client as xmlrpclib except ImportError: @@ -399,6 +405,9 @@ class SavepointCase(SingleTransactionCase): class ChromeBrowser(): def __init__(self): + if websocket is None: + _logger.warning("websocket-client module is not installed") + raise unittest.SkipTest("websocket-client module is not installed") self.devtools_port = PORT + 2 self.ws_url = '' # WebSocketUrl self.ws = None # websocket