Vasiliy Faronov
Vasiliy Faronov

Reputation: 12310

How can I run Django application tests together with other tests?

I’m working on a project composed of two Python packages. foo contains some common business logic and foo.webapp contains a Django app providing an API over it. Module foo.tests contains unittest cases for the common logic, and foo.webapp.tests for the API. Plus there’s a Django project for running the API. So it looks like this:

foo-root/
    foo/
        __init__.py
        some_logic.py
        other_logic.py
        tests.py
        webapp/
            __init__.py
            urls.py
            views.py
            tests.py

    django_project/
        manage.py
        settings.py
        urls.py

I want to keep foo.tests separate from foo.webapp.tests, so when I do django_project/manage.py test, it should only run the latter. But I also want a way to run both test suites together, with one progress bar, one fail count etc. Can I accomplish this, and if yes, how?

Upvotes: 3

Views: 137

Answers (1)

Vasiliy Faronov
Vasiliy Faronov

Reputation: 12310

I wrote a custom Django test runner along the lines of django-alltestsrunner (but instead of discovering the tests automatically, I specify a list of modules in settings).

Now, when I do django_project/manage.py test, it runs all the tests. When I do django_project/manage.py test foo.webapp.tests, it runs only the API tests.

Upvotes: 1

Related Questions