views:

24

answers:

1

I'm using django-nose to test our Django projects. It is common to split large test suites inside an application in Django like this:

myapp/
  __init__.py
  models.py
  tests/
    __init__.py
    test_views.py
    test_models.py
  views.py

tests/__init__.py would look like this:

from test_views import *
from test_models import *

Since Django will look for tests in myapp.tests, everything works as expected. Nose on the other hand will find the tests in tests_*.py and import them again in __init__.py. This results in the total number of tests reported being double what they should be.

Any ways around this problem (other than never using sub-modules) that will correctly report the tests with both django-nose and the default Django test runner?

A: 

Any ways around this problem (other than never using sub-modules)

Don't include the lines

from test_views import *
from test_models import *

in tests/__init__.py. What are those lines accomplishing?

Max
"Django will look for tests in `myapp.tests`"
Pete
Really? If you omit, the tests run 0 times, and if you include, the tests run 2 times? That is bizarre behavior.I use standard nose (as opposed to django-nose), so perhaps my expectations are wrong. However, my understanding is that the purpose of nose is to automatically find tests, thus avoiding extraneous code (e.g., unnecessary imports).
Max