From a183f2102b4f9371e4dbe5e397494bd2918981fc Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Wed, 2 Sep 2020 12:57:48 +0000 Subject: [PATCH] [FIX] core: make --test-file work with symlinked modules While individual addons paths are normalised, module and resource paths are not. As a result, when symlinking modules into directories on the addons path, the path of test modules is only half-normalized: it's normalised up to the addon path (which likely did not need it in that setup) but not above that. This is an issue when using `--test-file`, because that path is fully normalised, and so the path of the provided test file and that of the corresponding test module will not match, leading to the tests unexpectedly not getting run. Normalize the test module's path before the comparison, using the same routing used for --test-file. closes odoo/odoo#59822 X-original-commit: 536809662e542994451be793cd09e87adbf31776 Signed-off-by: Xavier Morel (xmo) --- odoo/service/server.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/odoo/service/server.py b/odoo/service/server.py index b7127783472..bd795bc14f5 100644 --- a/odoo/service/server.py +++ b/odoo/service/server.py @@ -1175,7 +1175,7 @@ def load_test_file_py(registry, test_file): for mod in [m for m in get_modules() if '/%s/' % m in test_file]: for mod_mod in loader.get_test_modules(mod): mod_path, _ = os.path.splitext(getattr(mod_mod, '__file__', '')) - if test_path == mod_path: + if test_path == config._normalize(mod_path): tests = loader.unwrap_suite( unittest.TestLoader().loadTestsFromModule(mod_mod)) suite = OdooSuite(tests)