Skip to content

Commit 666d427

Browse files
committed
Start the HTTP server on threaded mode to allow HttpCase tests
1 parent 839c728 commit 666d427

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/doblib/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION = "0.20.0"
1+
VERSION = "0.20.1"

src/doblib/ci.py

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import glob
55
import os
66
import shutil
7+
import signal
78
import sys
89
from fnmatch import fnmatch
910

@@ -22,6 +23,15 @@ def load_ci_arguments(args):
2223
default=False,
2324
help="Write the fixes back if supported by the tool",
2425
)
26+
parser.add_argument(
27+
"--no-http",
28+
action="store_true",
29+
default=False,
30+
help="Don't start the HTTP server for pytest tests. Useful to speed up tests",
31+
)
32+
parser.add_argument(
33+
"--no-force-threaded",
34+
)
2535
return parser.parse_known_args(args)
2636

2737

@@ -291,10 +301,20 @@ def base_case_run(self, result):
291301
if hasattr(pytest_odoo, "monkey_patch_resolve_pkg_root_and_module_name"):
292302
pytest_odoo.monkey_patch_resolve_pkg_root_and_module_name()
293303

304+
def _pytest_start_server(self):
305+
# pylint: disable=C0415,E0401,W0611
306+
# ruff: noqa: F401
307+
from odoo.service import server
308+
309+
server.start(preload=[], stop=True)
310+
signal.signal(signal.SIGINT, signal.default_int_handler)
311+
312+
if hasattr(server.server, "http_spawn"):
313+
server.server.http_spawn()
314+
294315
def test(self, args=None):
295316
"""Run tests"""
296-
if not args:
297-
args = []
317+
test_args, args = load_ci_arguments(args or [])
298318

299319
if not self._init_odoo():
300320
return False
@@ -321,6 +341,11 @@ def test(self, args=None):
321341
with self._manage():
322342
config.parse_config(["-c", base.ODOO_CONFIG])
323343
report_configuration()
344+
345+
if not test_args.no_http:
346+
config["workers"] = 0
347+
self._pytest_start_server()
348+
324349
# Pass the arguments to pytest
325350
sys.argv = sys.argv[:1] + args
326351
result = pytest.main()

0 commit comments

Comments
 (0)