3
# Load and runs the test from the utest subdirectory
4
# your unittests should append ".." to their path to
5
# find the files relative to this directory
14
if __name__ != '__main__':
15
prefix = __name__[:-5]
20
# If we are not called directly, we have
21
# to append this path to sys.path so our
22
# subtests will find their files
23
this_dir = os.path.dirname(__file__)
25
sys.path.append(this_dir)
27
suite = unittest.TestSuite()
28
l = unittest.TestLoader()
30
dname = os.path.dirname(__file__)
32
for f in glob('%s/utest/*.py' % dname):
33
if os.path.basename(f) == '__init__.py':
36
modname = '%sutest.%s' % (prefix, os.path.basename(f)[:-3])
39
tests = l.loadTestsFromName(modname)
43
sys.path.remove(this_dir)
50
runner = unittest.TextTestRunner()
52
return unittest.TestResult()
55
if __name__ == '__main__':
2
This file demonstrates two different styles of tests (one doctest and one
3
unittest). These will both pass when you run "manage.py test".
5
Replace these with more appropriate tests for your application.
8
from django.test import TestCase
10
class SimpleTest(TestCase):
11
def test_basic_addition(self):
13
Tests that 1 + 1 always equals 2.
15
self.failUnlessEqual(1 + 1, 2)
17
__test__ = {"doctest": """
18
Another way to test that 1 + 1 is equal to 2.