[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
This commit is contained in:
+10
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user