0

I have written a small unit test for my django view .My project structure is like

Project_name/

         apps/

              module1/
                      tests.py
              module2/
                      tests.py

this is my dir structure i am executing the tests by using the command :

$python manage.py test_coverage module1 module2 -v2

then it executing the test nicely but now i have change dir structure little bit i have created a new directory tests/ in that i have kept my all test files

project_name/

       apps/

            module1/
                    tests/
                         test_basic.py
                         test_detail.py

Now i can able to execute those tests which are in dir with the same above command ,is their is any alternative way to execute such tests?

Shashi
  • 2,137
  • 3
  • 22
  • 37

1 Answers1

3

The simplest solution is to add __init__.py file to tests/ package containing following lines:

from .test_basic import *
from .test_detail import *

And then run all the tests with:

$ python manage.py test module1
Łukasz
  • 35,061
  • 4
  • 33
  • 33
  • Hye Łukasz its works...very thanks.But can u plz explain me why and when we need to use dot(.) while importing files. – Shashi Jun 08 '11 at 11:48
  • @Shashi [See here for Python relative imports](http://www.python.org/dev/peps/pep-0328/#id10). – Evan Porter Jun 08 '11 at 20:58