Ticket #3253: runtests.diff
| File runtests.diff, 3.6 kB (added by mir@noris.de, 2 years ago) |
|---|
-
a/django/core/management.py
old new 1242 1242 test_module = __import__(test_module_name, {}, {}, test_path[-1]) 1243 1243 test_runner = getattr(test_module, test_path[-1]) 1244 1244 1245 test_runner(app_list, verbosity) 1245 failures = test_runner(app_list, verbosity) 1246 if failures: 1247 sys.exit(1) 1248 else: 1249 sys.exit(0) 1250 1246 1251 test.help_doc = 'Runs the test suite for the specified applications, or the entire site if no apps are specified' 1247 1252 test.args = '[--verbosity] ' + APP_ARGS 1248 1253 -
a/django/test/simple.py
old new 64 64 looking for doctests and unittests in models.py or tests.py within 65 65 the module. A list of 'extra' tests may also be provided; these tests 66 66 will be added to the test suite. 67 68 Returns the number of failures. 67 69 """ 68 70 setup_test_environment() 69 71 … … 79 81 old_name = settings.DATABASE_NAME 80 82 create_test_db(verbosity) 81 83 management.syncdb(verbosity, interactive=False) 82 unittest.TextTestRunner(verbosity=verbosity).run(suite)84 test_result = unittest.TextTestRunner(verbosity=verbosity).run(suite) 83 85 destroy_test_db(old_name, verbosity) 84 86 85 87 teardown_test_environment() 88 return len(test_result.failures) -
a/docs/testing.txt
old new 379 379 380 380 When the tests have all been executed, the test database is destroyed. 381 381 382 You can use the exit code of ``manage.py test`` for automation: it is 383 0 in case of success, and 1 in case of any test failures. 384 382 385 Using a different testing framework 383 386 =================================== 384 387 … … 398 401 #. Running the Unit Tests and Doctests that are found 399 402 #. Destroying the test database. 400 403 #. Performing global post-test teardown 404 #. Returning the number of failures 401 405 402 406 If you define your own test runner method and point ``TEST_RUNNER`` 403 407 at that method, Django will execute your test runner whenever you run -
a/tests/runtests.py
old new 118 118 119 119 # Run the test suite, including the extra validation tests. 120 120 from django.test.simple import run_tests 121 run_tests(test_models, verbosity, extra_tests=extra_tests)121 failures = run_tests(test_models, verbosity, extra_tests=extra_tests) 122 122 123 123 # Restore the old settings 124 124 settings.INSTALLED_APPS = old_installed_apps … … 127 127 settings.TEMPLATE_DIRS = old_template_dirs 128 128 settings.USE_I18N = old_use_i18n 129 129 130 return failures 131 130 132 if __name__ == "__main__": 131 133 from optparse import OptionParser 132 134 usage = "%prog [options] [model model model ...]" … … 140 142 if options.settings: 141 143 os.environ['DJANGO_SETTINGS_MODULE'] = options.settings 142 144 143 django_tests(int(options.verbosity), args) 145 failures = django_tests(int(options.verbosity), args) 146 if failures: 147 sys.exit(1) 148 else: 149 sys.exit(0)
