summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/core/management.py5
-rw-r--r--django/test/simple.py7
2 files changed, 10 insertions, 2 deletions
diff --git a/django/core/management.py b/django/core/management.py
index ae610e696d..953eeca734 100644
--- a/django/core/management.py
+++ b/django/core/management.py
@@ -1240,7 +1240,10 @@ def test(app_labels, verbosity=1):
test_module = __import__(test_module_name, {}, {}, test_path[-1])
test_runner = getattr(test_module, test_path[-1])
- test_runner(app_list, verbosity)
+ failures = test_runner(app_list, verbosity)
+ if failures:
+ sys.exit(failures)
+
test.help_doc = 'Runs the test suite for the specified applications, or the entire site if no apps are specified'
test.args = '[--verbosity] ' + APP_ARGS
diff --git a/django/test/simple.py b/django/test/simple.py
index 0cecc6b4fc..200f150594 100644
--- a/django/test/simple.py
+++ b/django/test/simple.py
@@ -63,6 +63,8 @@ def run_tests(module_list, verbosity=1, extra_tests=[]):
looking for doctests and unittests in models.py or tests.py within
the module. A list of 'extra' tests may also be provided; these tests
will be added to the test suite.
+
+ Returns the number of tests that failed.
"""
setup_test_environment()
@@ -77,7 +79,10 @@ def run_tests(module_list, verbosity=1, extra_tests=[]):
old_name = settings.DATABASE_NAME
create_test_db(verbosity)
- unittest.TextTestRunner(verbosity=verbosity).run(suite)
+ result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
destroy_test_db(old_name, verbosity)
teardown_test_environment()
+
+ return len(result.failures)
+ \ No newline at end of file