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
.
Asked
Active
Viewed 3,287 times
9
![](../../users/profiles/378638.webp)
Hakan B.
- 2,001
- 21
- 28
-
2besides `grep -R "^\w*def test_.*\(.*\)\:$" --include "*.py"`? – Thomas May 03 '13 at 06:57
-
1Running that on OS X 10.8.3 returned `grep: warning: recursive search of stdin` and the process hung indefinitely without returning any results. Modifying the command to `grep -R "def test_" --include "*.py" .` worked for me. Thanks for the clever solution. – Hakan B. May 03 '13 at 07:25
1 Answers
14
-
4Are you sure this works? It sounds good in theory but running your command returns `./manage.py: error: no such option: --collect-only`. I'm using Django 1.4.4 and using Nose as the test runner via django-nose. – Hakan B. May 21 '13 at 00:58
-
Yes, I've used it for a long time before. Have you added `django_nose` to the INSTALLED_APPS and set `TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'`? – alecxe May 21 '13 at 04:55
-
Hm, do you see `nose` command-line options while running `manage.py` with `--help`? – alecxe May 21 '13 at 09:04
-
I don't see `nose` options when running either `manage.py --help` or `mange.py test --help`, unfortunately. It's strange because I can see my tests are definitely being run via `nose`. I tried reinstalling `django-nose` but no luck. It must be something on my end. Thanks for your help. – Hakan B. May 21 '13 at 20:23
-
2You are welcome. Please try to move `django_nose` to the end of `INSTALLED_APPS`. – alecxe May 21 '13 at 20:26
-
That did it, thanks! I now see the `nose` command-line options and your original answer to the question works as well. – Hakan B. May 21 '13 at 20:31