aboutsummaryrefslogtreecommitdiffstats
path: root/examples/runtests.py
diff options
context:
space:
mode:
Diffstat (limited to 'examples/runtests.py')
-rw-r--r--examples/runtests.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/examples/runtests.py b/examples/runtests.py
new file mode 100644
index 00000000..fd79bc64
--- /dev/null
+++ b/examples/runtests.py
@@ -0,0 +1,27 @@
+import os
+import sys
+os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
+
+from django.conf import settings
+from django.test.utils import get_runner
+
+def main():
+ TestRunner = get_runner(settings)
+
+ if hasattr(TestRunner, 'func_name'):
+ # Pre 1.2 test runners were just functions,
+ # and did not support the 'failfast' option.
+ import warnings
+ warnings.warn(
+ 'Function-based test runners are deprecated. Test runners should be classes with a run_tests() method.',
+ DeprecationWarning
+ )
+ failures = TestRunner(None)
+ else:
+ test_runner = TestRunner()
+ failures = test_runner.run_tests(None)
+
+ sys.exit(failures)
+
+if __name__ == '__main__':
+ main()