Enabeling tests during build: DB_NAME missing

I want to enable test during the compilation of tryton modules.
However, it seems a DB_NAME is expected in all tests.
How and what should be provided?


[ 29s] ============================= test session starts ==============================

[ 29s] platform linux – Python 3.8.10, pytest-6.2.4, py-1.10.0, pluggy-0.13.1 – /usr/bin/python3.8
[ 29s] cachedir: .pytest_cache
[ 29s] rootdir: /home/abuild/rpmbuild/BUILD/trytond-6.0.5
[ 33s] collecting … collected 111 items / 57 errors / 54 selected
[ 33s]
[ 33s] ==================================== ERRORS ====================================
[ 33s] ________________ ERROR collecting trytond/tests/test_access.py _________________
[ 33s] trytond/tests/test_access.py:7: in
[ 33s] from trytond.tests.test_tryton import activate_module, with_transaction
[ 33s] frozen importlib._bootstrap:991: in _find_and_load
[ 33s] ???
[ 33s] frozen importlib._bootstrap:975: in _find_and_load_unlocked
[ 33s] ???
[ 33s] frozen importlib._bootstrap:671: in _load_unlocked
[ 33s] ???
[ 33s] /usr/lib/python3.8/site-packages/_pytest/assertion/rewrite.py:170: in exec_module
[ 33s] exec(co, module.dict)
[ 33s] trytond/tests/test_tryton.py:44: in
[ 33s] DB_NAME = os.environ[‘DB_NAME’]
[ 33s] /usr/lib64/python3.8/os.py:675: in getitem
[ 33s] raise KeyError(key) from None
[ 33s] E KeyError: ‘DB_NAME’

The environment variable is set by the run-tests script.

For me it seems your are wrongly instanciating our test suite, but as you did not explain how you are running them we can not give any advice.

This is quite likely, as the Documentation did not mention how to run the tests. Or I did not find the documentation. I called the tests as mostly for python-packages:

pytests -v tests

Sincerly I did not know about pytests, so not sure how to run our test suite using this tool.

If you have a look at our CI, you will see that we normally use tox to install the package and run its tests. Indeed, all the trytond modules have a tox.ini file which defines the configuration. This ensures that the module works correctly but also that the package is correctly built so the module will work when installed with pip.

Thank you Sergi.
The build service can run the test script (trytond/tests/run-tests.py) as well, and succeeds with a couple of DeprecationWarnings: Ran 1378 tests in 84.584s