-
Notifications
You must be signed in to change notification settings - Fork 2
/
runtests.py
44 lines (37 loc) · 1.1 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
#!/usr/bin/env python
import logging
import os
import sys
from os.path import abspath, dirname
import django
from django.conf import settings
from django.test.runner import DiscoverRunner
from edc_test_utils import DefaultTestSettings
app_name = "django_audit_fields"
base_dir = dirname(abspath(__file__))
DEFAULT_SETTINGS = DefaultTestSettings(
calling_file=__file__,
BASE_DIR=base_dir,
APP_NAME=app_name,
ETC_DIR=os.path.join(base_dir, app_name, "tests", "etc"),
INSTALLED_APPS=[
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.messages",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.staticfiles",
"django_revision.apps.AppConfig",
f"{app_name}.apps.AppConfig",
],
).settings
def main():
if not settings.configured:
settings.configure(**DEFAULT_SETTINGS)
django.setup()
failures = DiscoverRunner(failfast=True).run_tests([f"{app_name}.tests"])
sys.exit(failures)
if __name__ == "__main__":
logging.basicConfig()
main()