forked from MidAtlanticPortal/madrona-features
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntests_pycharm.py
33 lines (25 loc) · 925 Bytes
/
runtests_pycharm.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
"""Modified test runner to help run the test app with PyCharm's Unittest
run configuration.
"""
from django.test.utils import get_runner
import os
import django
from django.conf import settings
class EnvironmentSetterUpper:
"""Class that does django setup prior to running tests, and (hopefully)
calls the test teardown.
"""
def __init__(self):
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
django.setup()
TestRunner = get_runner(settings)
self.test_runner = TestRunner()
self.test_runner.setup_test_environment()
suite = self.test_runner.build_suite([], None)
self.old_config = self.test_runner.setup_databases()
def __del__(self):
pass
self.test_runner.teardown_databases(self.old_config)
self.test_runner.teardown_test_environment()
setter_upper = EnvironmentSetterUpper()
from tests.tests import *