[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) <xmo@odoo.com>
This commit is contained in:
Xavier Morel
2020-10-13 07:25:13 +00:00
parent 11c710d990
commit a183f2102b
+1 -1
View File
@@ -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)