I am attempting to run a subset of tests as part of a build; but I've been unable to run individual tests with python3 -m unittest <test>
.
I have tried to follow the documentation and also read through: Running unittest with typical test directory structure, but I am still having no luck.
The directory structure is like this:
new_project
├── new_project
├──── __init__.py
├──── pipeline.py
├── regression_tests
├──── __init__.py
├──── helpers.py
├──── test_pipeline.py
└──── test_connectivity.py
Running python3 -m unittest discover
at the new_project
level runs all tests fine; but trying to run a subset fails now matter how I try to cut it:
python3 -m unittest regression_tests
With the result: Ran 0 tests in 0.000s
python3 -m unittest regression_tests.test_pipeline
python3 -m unittest regression_tests.test_pipeline.TestClass
python3 -m unittest regression_tests.test_pipeline.TestClass.test_method
--- or ---
python3 -m unittest regression_tests/test_pipeline.py
With the Errors: AttributeError: 'module' object has no attribute 'test_pipeline'
Finally for completeness this also fails (as I would expect as the PYTHONPATH would be incorrectly set):
cd regression_tests
python3 -m unittest test_pipeline
With the Error: ImportError: No module named 'regression_tests'
(The error is thrown on the line from regression_tests.helpers import helper_method
.)
I don't think I'm doing anything that's non-standard here. Why is it that unittest discover
works, but that unittest <test>
fails?