Wednesday, 26 December 2018

Recursive unittest discovery with python3 and without __init__.py files

I have project with the following directory structure:

.
├── requirements.txt
├── main.py
├── tests
    ├── unit
    │   └── test_thing1.py
    │   └── test_thing2.py
    └── integration.py
        └── test_integration_thing1.py
        └── test_integration_thing2.py

I want to run all tests with one command. If I do python -m unittest discover, no tests are executed.

I found this question that suggest adding a __init__.py file to make packages out of the unit and integration folders. The solution works, and all tests are running this way.

But since I'm using python3 and __init__.py files are not required with implicit namespace packages, I was wondering if there was a way to make this works without those __init__.py files.



from Recursive unittest discovery with python3 and without __init__.py files

No comments:

Post a Comment