44import glob
55import os
66import shutil
7+ import signal
78import sys
89from 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