Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display list of all tests in a Django project

Is there an easy way to get a list of all tests in a Django project without running the tests themselves? I was hoping for something like ./manage.py test --list.

like image 487
Hakan B. Avatar asked May 03 '13 03:05

Hakan B.


People also ask

What is Django test runner?

If you are writing a reusable application you may want to use the Django test runner to run your own test suite and thus benefit from the Django testing infrastructure. A common practice is a tests directory next to the application code, with the following structure: runtests. py polls/ __init__. py models.

What order Django tests are run?

Order in which tests are executedAll TestCase subclasses are run first. Then, all other Django-based tests (test cases based on SimpleTestCase , including TransactionTestCase ) are run with no particular ordering guaranteed nor enforced among them. Then any other unittest.

What are Django tests?

Django provides a test framework with a small hierarchy of classes that build on the Python standard unittest library. Despite the name, this test framework is suitable for both unit and integration tests. The Django framework adds API methods and tools to help test web and Django-specific behavior.

How do I run test PY?

If you're using the PyCharm IDE, you can run unittest or pytest by following these steps: In the Project tool window, select the tests directory. On the context menu, choose the run command for unittest . For example, choose Run 'Unittests in my Tests…'.


1 Answers

In my opinion, the more correct way is to use the actual tool for running tests. E.g. in case of nose:

./manage.py test <app> --verbosity 2 --collect-only

FYI, py.test also has --collectonly option to print tests instead of executing.

Also see:

  • List all Tests Found by Nosetest
like image 63
alecxe Avatar answered Oct 17 '22 06:10

alecxe