Spirit/runtests.py
Benjamin ABEL c64641d87a Separate example and tests
Each folder has is own settings and urls and can be tested with
`runtests.py`

1. `./runtests` run tests with `tests/settings.py` file
2. `./runtests example` run tests with `example/settings.py` file

`runtests.py` write to stdout the settings file used.
2014-11-25 14:24:50 +01:00

46 lines
1013 B
Python
Executable File

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import os
import sys
import logging
EXAMPLE = 'example' in sys.argv
if EXAMPLE:
# Run tests with example settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'example.settings' # pragma: no cover
else:
# Run tests with tests settings
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.settings'
import django
from django.test.runner import DiscoverRunner
def log_warnings():
logger = logging.getLogger('py.warnings')
handler = logging.StreamHandler()
logger.addHandler(handler)
def run_tests():
sys.stdout.write(("\nRunning spirit test suite, using settings %(settings)r\n\n")
% {"settings": os.environ['DJANGO_SETTINGS_MODULE'], }
)
test_runner = DiscoverRunner()
failures = test_runner.run_tests(["tests", ])
sys.exit(failures)
def start():
django.setup()
log_warnings()
run_tests()
if __name__ == "__main__":
start()