This question is more suited for the django-users mailing list, this
list is intended for discussing development of django internals.
--
Honza Král
E-Mail: Honza...@gmail.com
ICQ#: 107471613
Phone: +420 606 678585
In case you haven't figured this out already, it can be done by
importing your unit test classes from the test/*.py modules in
tests/__init__.py
Gary
That is exactly what I have done at my work, just a few days ago. I
put the code below into the tests/__init__.py. You can use it as is.
def get_test_modules():
from os import path, listdir
names = set()
for f in listdir(path.dirname(__file__)):
if f.startswith('.') or f.startswith('__'):
continue
names.add(f.split('.')[0])
for name in names:
yield (name, __import__('%s.%s' % (__name__, name), {}, {}, ['']))
def setup_doc_tests():
for name, module in get_test_modules():
# Try to find an API test in the current module, if it fails continue.
try:
api_tests = module.__test__['API_TESTS']
except (AttributeError, TypeError, KeyError):
continue
# Import possible dependecies of the API test from the current module.
for k, v in module.__dict__.iteritems():
if k.startswith('__'):
continue
globals()[k] = v
# Attach the API test to the __test__ dictionary if it exists or create it.
try:
globals()['__test__'][name] = api_tests
except KeyError:
globals()['__test__'] = {name: api_tests}
def setup_unit_tests():
import unittest
for name, module in get_test_modules():
# Import each TestCase from the current module.
for k, v in module.__dict__.iteritems():
if not (isinstance(v, type) and issubclass(v, unittest.TestCase)):
continue
globals()[k] = v
setup_doc_tests()
setup_unit_tests()
from myproj.tests.model_tests import *
from myproj.tests.view_tests import *
(etc)
2008/5/23 Sebastian Noack <sebasti...@googlemail.com>:
Well, you don't have to use my code. Of course you can just import each
unit test explicitly.
The reason why I have written this code, was to don't have to import
all unit tests explicit and to support doc tests as well.
Regards
Sebastian Noack