[REF] server: better warnings when using --test-file

We add two warnings to make the --test-file argument more user friendly:
- one when the test file does not exist
example:
./odoo-bin -d master --test-file ./addonss/stock/tests/test_quant.py
before:
INFO master odoo.service.server: loading test file ./addonss/stock/tests/test_quant.py
after:
WARNING master odoo.service.server: test file ./addonss/stock/tests/test_quant.py cannot be found
- one when the test file is not a python file

In both cases, nothing was being tested but the server did not say why.

closes odoo/odoo#34808

Signed-off-by: Xavier Dollé (xdo) <xdo@odoo.com>
This commit is contained in:
Simon Lejeune
2019-07-12 07:14:38 +00:00
parent 50163143a9
commit 22221a2b57
+7 -3
View File
@@ -1123,9 +1123,13 @@ def preload_registries(dbnames):
# run test_file if provided
if config['test_file']:
test_file = config['test_file']
_logger.info('loading test file %s', test_file)
with odoo.api.Environment.manage():
if test_file.endswith('py'):
if not os.path.isfile(test_file):
_logger.warning('test file %s cannot be found', test_file)
elif not test_file.endswith('py'):
_logger.warning('test file %s is not a python file', test_file)
else:
_logger.info('loading test file %s', test_file)
with odoo.api.Environment.manage():
load_test_file_py(registry, test_file)
# run post-install tests