Search code examples
djangodjango-tests

Django tests not finding my tests


When I run tests, django runs 0 tests. This is my project structure:

manage.py
- app/
  - main_app/
    - test/
       - tests_v1.py
       - tests_v2.py

I use this command:

python manage.py test --pattern="tests_v*.py"

Django runs 0 tests in 0 seconds. What am I missing?


Solution

  • Add __init__.py file inside test directory. Then import all inside it like

    In __init__.py

    from tests_v1 import *
    from tests_v2 import *
    

    Note

    Name tests_v1 as tests_v1.py