Ticket #12373: keepdb.diff
File keepdb.diff, 2.5 KB (added by , 15 years ago) |
---|
-
django/test/simple.py
101 101 raise ValueError("Test label '%s' does not refer to a test class" % label) 102 102 return TestClass(parts[2]) 103 103 104 def run_tests(test_labels, verbosity=1, interactive=True, extra_tests=[]):104 def run_tests(test_labels, verbosity=1, interactive=True, keepdb=False, extra_tests=[]): 105 105 """ 106 106 Run the unit tests for all the test labels in the provided list. 107 107 Labels must be of the form: … … 143 143 from django.db import connection 144 144 connection.creation.create_test_db(verbosity, autoclobber=not interactive) 145 145 result = unittest.TextTestRunner(verbosity=verbosity).run(suite) 146 connection.creation.destroy_test_db(old_name, verbosity) 146 if not keepdb: 147 connection.creation.destroy_test_db(old_name, verbosity) 147 148 148 149 teardown_test_environment() 149 150 -
django/core/management/commands/test.py
9 9 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output'), 10 10 make_option('--noinput', action='store_false', dest='interactive', default=True, 11 11 help='Tells Django to NOT prompt the user for input of any kind.'), 12 make_option('--keepdb', action='store_true', dest='keepdb', default=False, 13 help='Do not destroy test db at the end of tests.'), 12 14 ) 13 15 help = 'Runs the test suite for the specified applications, or the entire site if no apps are specified.' 14 16 args = '[appname ...]' … … 20 22 21 23 verbosity = int(options.get('verbosity', 1)) 22 24 interactive = options.get('interactive', True) 25 keepdb = options.get('keepdb', False) 23 26 24 27 test_path = settings.TEST_RUNNER.split('.') 25 28 # Allow for Python 2.5 relative paths … … 29 32 test_module_name = '.' 30 33 test_module = __import__(test_module_name, {}, {}, test_path[-1]) 31 34 test_runner = getattr(test_module, test_path[-1]) 32 33 failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive) 35 failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive, keepdb=keepdb) 34 36 if failures: 35 37 sys.exit(failures)