Setuptools - how to run unittest test suite when tests are not in main directory?
我有以下模块结构:
1 2 3 4 5 6 | main ->module --->tests ----->test_module.py --->module.py ->setup.py |
我使用
1 2 3 4 5 6 7 | from setuptools import setup setup( name='module', packages=['module', ], test_suite='module/tests', ) |
生成以下错误消息:
====================================================================== 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:
设置
====================================================================== 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:
有人可以帮我弄这个吗?
1 | test_suite='module.tests', |