Skip to content

Commit f6b5fdc

Browse files
author
Emmanouil Konstantinidis
committed
Working tests
1 parent 93a8b6f commit f6b5fdc

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

runtests.py

+17-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
#!/usr/bin/env python
2+
import os
23
import sys
34
import subprocess
5+
import django
6+
from django.conf import settings
7+
from django.test.utils import get_runner
48

59

6-
FLAKE8_ARGS = ['demo/project/', 'rest_framework_docs', '--ignore=E501']
10+
FLAKE8_ARGS = ['demo/project/', 'rest_framework_docs', 'tests/', '--ignore=E501']
711

812

913
def exit_on_failure(command, message=None):
@@ -17,4 +21,16 @@ def flake8_main(args):
1721
print("" if command else "Success. flake8 passed.")
1822
return command
1923

24+
25+
def django_tests_main():
26+
if __name__ == "__main__":
27+
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
28+
django.setup()
29+
TestRunner = get_runner(settings)
30+
test_runner = TestRunner()
31+
failures = test_runner.run_tests(["tests"])
32+
sys.exit(bool(failures))
33+
2034
exit_on_failure(flake8_main(FLAKE8_ARGS))
35+
36+
django_tests_main()

tests/__init__.py

Whitespace-only changes.

tests/settings.py

+14
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
import os
2+
3+
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
4+
15
SECRET_KEY = 'django-rest-framework-docs-key'
26

7+
# Database
8+
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
9+
10+
DATABASES = {
11+
'default': {
12+
'ENGINE': 'django.db.backends.sqlite3',
13+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
14+
}
15+
}
16+
317
INSTALLED_APPS = [
418
"rest_framework",
519
]

tests/setup.py

-15
This file was deleted.

0 commit comments

Comments
 (0)