forked from jazzband/django-push-notifications
-
Notifications
You must be signed in to change notification settings - Fork 0
/
runtests.py
executable file
·49 lines (36 loc) · 1.07 KB
/
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
import os
import sys
import unittest
def setup():
# add test/src folders to sys path
test_folder = os.path.abspath(os.path.dirname(__file__))
src_folder = os.path.abspath(os.path.join(test_folder, os.pardir))
sys.path.insert(0, test_folder)
sys.path.insert(0, src_folder)
# define settings
import django.conf
os.environ[django.conf.ENVIRONMENT_VARIABLE] = "settings"
# set up environment
from django.test.utils import setup_test_environment
setup_test_environment()
# See https://docs.djangoproject.com/en/dev/releases/1.7/#app-loading-changes
import django
if django.VERSION >= (1, 7, 0):
django.setup()
# set up database
from django.db import connection
connection.creation.create_test_db()
def tear_down():
# destroy test database
from django.db import connection
connection.creation.destroy_test_db("not_needed")
# teardown environment
from django.test.utils import teardown_test_environment
teardown_test_environment()
# fire in the hole!
if __name__ == "__main__":
setup()
import tests
unittest.main(module=tests)
tear_down()