Recursive unittest opening with python3 and without __init__.py files

I have a 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 a single command . If I execute python -m unittest discover, tests are not executed.

I found this question suggesting adding a file __init__.pyto create packages from folders unitand integration. The solution works, and all tests work this way.

But since I am using python3 and __init__.pyfiles are not required with an implicit namespace package , I was wondering if there is a way to do this without these __init__.pyfiles.

+4
source share
1 answer

pytest. .

pip (pip install pytest), pytest tests.

-1

Source: https://habr.com/ru/post/1688296/


All Articles