Fusion
Fusion

Reputation: 5472

Django 2.0 - Make test worker to run tests in non-app folder

In Django 2.0, I have following project structure, which I can't change, no matter what:

grocery_store_website
    manage.py
    grocery_store  # contains wsgi, settings,etc.
    app1
    app1
    non-app-utils
        __init__.py
        helpers.py
        serializers.py
        model_mixins.py
        tests
            test_helpers.py  # I want test runner to run these.

It turned out, I need to write unit tests for non-app-utils. Mentioned directory is not a registered Django App and never will be. These tests must be located in tests directory, located in non-app-utils. How can I make Django's test runner to discover and run also tests from non-app-utils directory?

If I run Django tests with directly specified path ./manage.py test utils.tests.test_helpers, it works. However ./manage.py test does not. Any ideas how to go on?

Upvotes: 0

Views: 221

Answers (1)

Fusion
Fusion

Reputation: 5472

Jerin Peter George suggested adding __init__.py file into non-app-utils directory. However, problem was, there is __init__.py file missing in non-app-utils/tests directory!

After I add those and run ./manage.py test, Django's test runner found my tests and ran them as I needed to!

Upvotes: 1

Related Questions