From 22221a2b573a4daad9457bb2329a84bcef15d5df Mon Sep 17 00:00:00 2001 From: Simon Lejeune Date: Thu, 11 Jul 2019 15:01:27 +0000 Subject: [PATCH] [REF] server: better warnings when using --test-file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- odoo/service/server.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/odoo/service/server.py b/odoo/service/server.py index 207d590e724..7fd576ab6d5 100644 --- a/odoo/service/server.py +++ b/odoo/service/server.py @@ -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