diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2007-02-26 12:52:01 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2007-02-26 12:52:01 +0000 |
| commit | f313e07b6e0914130b613c3491b2b019ca003dc7 (patch) | |
| tree | 43f5d09e7637dc5f88c185a80dc057368caa4b52 /django | |
| parent | c27ba0b2097267796bc97daea81ee62dd10554ff (diff) | |
Fixed #3253 -- Exposed the number of failed tests as a return code in manage.py and runtests.py.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@4608 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management.py | 5 | ||||
| -rw-r--r-- | django/test/simple.py | 7 |
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 |
