How do I tell django-nose where my tests are? #34

hekevintran opened this Issue May 19, 2011 · 15 comments

I have my tests for a Django application in a tests directory:

├── tests
│   ├──
│   ├──
│   └──

The Django test runner requires that I put a suite() function in the file of my application's tests directory. That function returns the test cases that will run when I do
$ python test my_app

I installed django-nose. When I try to run the tests with django-nose, 0 tests are run:
$ python test my_app

If I point directly at the test module, the tests are run:
$ python test my_project.apps.my_app.tests.storage_tests

Why does django-nose's test runner not find my tests? What must I do?


Do you have an in my_project/apps? nose won't recurse further into directories if they don't look like Python packages.


Yes I do. All directories in my project have an file.


Interestingly the following line works.
$ python test my_project/apps/my_app/

I don't know why this works and the other command doesn't. I guess this is sufficient though.

There's nothing you can do by specifying the module path that you cannot do by specifying the directory path right?


nose behaves a bit diferent than Django. It doesn't know about INSTALLED_APPS, it just knows about the python import path. If it's possible for you to do ./ shell and import my_app then nose will be able to find it. If you have to import apps.my_app then you'll have to use that import path for nose.


We work with hekevintran together, and this command still doesn't work:

$ python test my_project.apps.my_app

although there are in all the folders. The my_project.apps.my_app has tests package in it, and in it. When we run it with the command above, it's ignored. My question is, what does nose consider a test?


@jbalogh is this still the case?

nose behaves a bit diferent than Django. It doesn't know about INSTALLED_APPS, it just knows about the python import path


Has this been resolved? This is an issue for a coworker (but not me). The only way he can execute tests is via:

$> python test our_app.tests.test_models


$> python test our_app/tests/*

When we turn on -v, it doesn't find any other tests (in fact, it executes none). @culebron, did you guys ever find a solution for this problem?



For anyone else who was trying to figure out how to do this, this is what I came up with. You can create a new python file, import the NoseTestSuiteRunner and any other django apps you need. You can also subclass the NoseTestSuiteRunner and provide a default list of apps to test when you run bin/django test. You could also set the import path here if needed.

In the example below running bin/django test is equivalent to running bin/django test my_django_app

Hope this helps.

from django_nose import NoseTestSuiteRunner
from some.path import my_django_app

class MyNoseTestSuiteRunner(NoseTestSuiteRunner):
    def run_tests(self, test_labels, *args, **kwargs):
        Django nose does not allow us to specify a default  app to test, so
        we can subclass to tell django nose to run the specified app if we
        do not specifically provide one on the command line.
        if len(test_labels) == 0:
            test_labels = ('my_django_app',)
        return super(NoseTestSuiteRunner, self).run_tests(test_labels, *args,

I would love if somebody could post a reduction of this—a teeny example project where django_nose doesn't find stuff. Sounds like something I'd like to fix (or at least make less surprising).


I had a similar issue. The django nose runner was not finding tests unless given the full path to the tests in just one directory (valid python package). Running tests -v3, I noticed the following:

nose.selector: INFO: /home/path/to/ is executable; skipped

When I changed the file permissions on those tests everything worked fine. Hope that helps someone.


It is worth trying setting the environment variable NOSE_INCLUDE_EXE to a non-empty string.

While (at least currently) this is set by default on win32 and cli, and on *nix systems the file should get made without execute permissions, it is possible that if a site were created on a Windows box and copied to something else, you could wind up with the execute bits set (I've seen that - don't remember the details). Setting execute permissions on on a linux system certainly prevents the test from running, and using:


makes it run again. If the OP is still having the problem, could he please try this?


export NOSE_INCLUDE_EXE=1 worked for me. In addition, I wasn't aware that there was a level 3 (level 2 appeared to make no difference) to the verbosity so once I tried running the tests I was able to see several .py is executable; skipped results.

Thanks everyone



Yes! This is what I was looking for! I run Ubuntu but the disk partition I'm working on is shared with Windows (NTFS), so al files are 'executable' (so as to say).

Thank you very much for the help.



This worked for me also by placing it in settings, thanks! I'm using Ubuntu.


This could be turned into a documentation hint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment