How to run unit tests with tox in a newly generated Tryton module?

I created a new module using the Tryton cookiecutter. When I try to run tox -e py39sqlite, I get this error:

FileNotFoundError: [Errno 2] No such file or directory: 'C:\\path\\to\\module\\sample\\.tox\\py39-sqlite\\lib\\site-packages\\trytond\\modules\\sample\\tryton.cfg'

Did I miss a step in setting up the module or running tox?

The name of the environment is py39-sqlite

Yes, I mistakenly posted py39sqlite instead of py39-sqlite, but I still couldn’t resolve my error

We need to full traceback of the error in order to understand anything.

This is the full traceback, I’m using a virtual environment to run the test command python -m unittest,

Removed Image

You need to run tox to run tests with tox.

I initially did run tox, here is my output,

PS C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production> tox -e py39-sqlite
.pkg: _optional_hooks> python c:\users\amrit\documents\continental\projects\tryton\main\venv\lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_editable> python c:\users\amrit\documents\continental\projects\tryton\main\venv\lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta __legacy__
.pkg: build_editable> python c:\users\amrit\documents\continental\projects\tryton\main\venv\lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta __legacy__
py39-sqlite: install_package> python -I -m pip install --force-reinstall --no-deps C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\.tmp\package\5\trytond_sample_production-7.4.0-0.editable-py3-none-any.whl
py39-sqlite: commands[0]> coverage run --omit=*/tests/* -m xmlrunner discover -s tests
C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\py39-sqlite\lib\site-packages\trytond\__init__.py:27: UserWarning: Timezone must be set to UTC instead of India Standard Time
  warnings.warn('Timezone must be set to UTC instead of %s' % time.tzname[0])

Running tests...
----------------------------------------------------------------------
.....................E
======================================================================
ERROR [0.004s]: test_xml_files (test_module.SampleProductionTestCase)
Test validity of the xml files of the module
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\py39-sqlite\lib\site-packages\trytond\tests\test_tryton.py", line 281, in wrapper
    result = func(*args, **kwargs)
  File "C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\py39-sqlite\lib\site-packages\trytond\tests\test_tryton.py", line 1076, in test_xml_files
    with file_open('%s/tryton.cfg' % self.module,
  File "C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\py39-sqlite\lib\site-packages\trytond\tools\misc.py", line 50, in file_open
    return io.open(path, mode, encoding=encoding)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\amrit\\Documents\\Continental\\Projects\\Tryton\\docker\\sample_production\\.tox\\py39-sqlite\\lib\\site-packages\\trytond\\modules\\sample_production\\tryton.cfg'

----------------------------------------------------------------------
Ran 22 tests in 11.968s

FAILED (errors=1)

Generating XML reports...
py39-sqlite: exit 1 (25.05 seconds) C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production> coverage run --omit=*/tests/* -m xmlrunner discover -s tests pid=28232
py39-sqlite: commands_post[0]> coverage report
Name          Stmts   Miss  Cover
---------------------------------
__init__.py       6      0   100%
---------------------------------
TOTAL             6      0   100%
py39-sqlite: commands_post[1]> coverage xml
Wrote XML report to coverage.xml
  py39-sqlite: FAIL code 1 (27.70=setup[2.20]+cmd[25.05,0.22,0.24] seconds)
  evaluation failed :( (28.66 seconds)

I suspect that your module is not importable.
Can you run it inside your virtualenv?

this was already run in the virtual environment

$ which python
/c/Users/amrit/Documents/Continental/Projects/Tryton/main/venv/Scripts/python
$ tox -e py39-sqlite
.pkg: _optional_hooks> python c:\users\amrit\documents\continental\projects\tryton\main\venv\lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta __legacy__
.pkg: get_requires_for_build_editable> python c:\users\amrit\documents\continental\projects\tryton\main\venv\lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta __legacy__
.pkg: build_editable> python c:\users\amrit\documents\continental\projects\tryton\main\venv\lib\site-packages\pyproject_api\_backend.py True setuptools.build_meta __legacy__
py39-sqlite: install_package> python -I -m pip install --force-reinstall --no-deps C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\.tmp\package\6\trytond_sample_production-7.4.0-0.editable-py3-none-any.whlpy3-none-any.whl
py39-sqlite: commands[0]> coverage run --omit=*/tests/* -m xmlrunner discover -s tests
C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\py39-sqlite\lib\site-packages\trytond\__init__.py:27: UserWarning: Timezone must be set to UTC instead of India Standard Time
  warnings.warn('Timezone must be set to UTC instead of %s' % time.tzname[0])

Running tests...
----------------------------------------------------------------------
.....................E
======================================================================
ERROR [0.003s]: test_xml_files (test_module.SampleProductionTestCase)
Test validity of the xml files of the module
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\py39-sqlite\lib\site-packages\trytond\tests\test_tryton.py", line 281, in wrapper
    result = func(*args, **kwargs)
  File "C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\py39-sqlite\lib\site-packages\trytond\tests\test_tryton.py", line 1076, in test_xml_files
    with file_open('%s/tryton.cfg' % self.module,
  File "C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production\.tox\py39-sqlite\lib\site-packages\trytond\tools\misc.py", line 50, in file_open
    return io.open(path, mode, encoding=encoding)
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\amrit\\Documents\\Continental\\Projects\\Tryton\\docker\\sample_production\\.tox\\py39-sqlite\\lib\\site-packages\\trytond\\modules\\sample_production\\tryton.cfg'

----------------------------------------------------------------------
Ran 22 tests in 11.703s

FAILED (errors=1)

Generating XML reports...
py39-sqlite: exit 1 (24.66 seconds) C:\Users\amrit\Documents\Continental\Projects\Tryton\docker\sample_production> coverage run --omit=*/tests/* -m xmlrunner discover -s tests pid=33628
py39-sqlite: commands_post[0]> coverage report
Name          Stmts   Miss  Cover
---------------------------------
__init__.py       6      0   100%
---------------------------------
TOTAL             6      0   100%
py39-sqlite: commands_post[1]> coverage xml
Wrote XML report to coverage.xml
  py39-sqlite: FAIL code 1 (27.52=setup[2.47]+cmd[24.66,0.20,0.19] seconds)
  evaluation failed :( (28.50 seconds)

I mean running trytond server with your module (not the tests).
Because I suspect that your module is not importable.

Do you mean this ?

import trytond.modules.party
import trytond.modules.sample_production

This is in my virtual environment
I added party, because it’s a standard module, I have it installed,

$ python script.py 
C:\Users\amrit\Documents\Continental\Projects\Tryton\main\venv\lib\site-packages\trytond\__init__.py:27: UserWarning: Timezone must be set to UTC instead of India Standard Time
  warnings.warn('Timezone must be set to UTC instead of %s' % time.tzname[0])
Traceback (most recent call last):
  File "C:\XXXXX\migration\script.py", line 2, in <module>
    import trytond.modules.sample_production
ModuleNotFoundError: No module named 'trytond.modules.sample_production'

Btw, I did do pip install . inside the folder I’m using to develop my module, after that, tests were working, but I was wondering if I have to pip install my development module, and check if it pass all the tests, I read somewhere I can use editable mode like pip install -e ., but I did that also, still getting the same traceback.