-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathruntests.py
32 lines (24 loc) · 903 Bytes
/
runtests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
import os
import unittest
if not 'DJANGO_SETTINGS_MODULE' in os.environ:
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
from django.conf import settings
from django.db import connection
from django.test.utils import setup_test_environment
from django.test.utils import teardown_test_environment
from django.utils.importlib import import_module
TEST_MODULES = ["tests.base"]
def run_tests():
setup_test_environment()
db_name = settings.DATABASE_NAME
suite = unittest.TestSuite()
for module_name in TEST_MODULES:
module = import_module(module_name)
suite.addTest(unittest.defaultTestLoader.loadTestsFromModule(module))
connection.creation.create_test_db()
unittest.TextTestRunner().run(suite)
connection.creation.destroy_test_db(db_name)
teardown_test_environment()
if __name__ == "__main__":
run_tests()