samedi 6 janvier 2018

Setuptools - how to run unittest test suite when tests are not in main directory?

I have a following module structure:

main
->module
--->tests
----->test_module.py
--->module.py
->setup.py

I have unit tests implemented using unittest package. When following this answer I set my setup.py file to be:

from setuptools import setup

setup(
    name='module',
    packages=['module', ],
    test_suite='module/tests',
)

Produced the following error message:

====================================================================== ERROR: tests (unittest.loader._FailedTest) ---------------------------------------------------------------------- ImportError: Failed to import test module: tests Traceback (most recent call last): File "/opt/conda/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName module = import(module_name) ModuleNotFoundError: No module named 'tests/module'


Ran 1 test in 0.000s

FAILED (errors=1) Test failed: error: Test failed:

When setting test_suite='tests I've got:

====================================================================== ERROR: tests (unittest.loader._FailedTest) ---------------------------------------------------------------------- ImportError: Failed to import test module: tests Traceback (most recent call last): File "/opt/conda/lib/python3.6/unittest/loader.py", line 153, in loadTestsFromName module = import(module_name) ModuleNotFoundError: No module named 'tests'


Ran 1 test in 0.000s

FAILED (errors=1) Test failed: error: Test failed:

Can someone help me with this?

Aucun commentaire:

Enregistrer un commentaire