Changeset 5752
- Timestamp:
- 07/23/07 07:14:32 (1 year ago)
- Files:
-
- django/trunk/django/core/management.py (modified) (3 diffs)
- django/trunk/django/test/simple.py (modified) (2 diffs)
- django/trunk/docs/testing.txt (modified) (2 diffs)
- django/trunk/tests/runtests.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/core/management.py
r5738 r5752 1332 1332 runfcgi.args = '[various KEY=val options, use `runfcgi help` for help]' 1333 1333 1334 def test(app_labels, verbosity=1 ):1334 def test(app_labels, verbosity=1, interactive=True): 1335 1335 "Runs the test suite for the specified applications" 1336 1336 from django.conf import settings … … 1351 1351 test_runner = getattr(test_module, test_path[-1]) 1352 1352 1353 failures = test_runner(app_list, verbosity )1353 failures = test_runner(app_list, verbosity=verbosity, interactive=interactive) 1354 1354 if failures: 1355 1355 sys.exit(failures) 1356 1356 1357 1357 test.help_doc = 'Runs the test suite for the specified applications, or the entire site if no apps are specified' 1358 test.args = '[--verbosity] ' + APP_ARGS1358 test.args = '[--verbosity] [--noinput]' + APP_ARGS 1359 1359 1360 1360 def load_data(fixture_labels, verbosity=1): … … 1632 1632 except IndexError: 1633 1633 parser.print_usage_and_exit() 1634 elif action in ('test', 'loaddata'): 1634 elif action == 'test': 1635 try: 1636 action_mapping[action](args[1:], int(options.verbosity), options.interactive) 1637 except IndexError: 1638 parser.print_usage_and_exit() 1639 elif action == 'loaddata': 1635 1640 try: 1636 1641 action_mapping[action](args[1:], int(options.verbosity)) django/trunk/django/test/simple.py
r5729 r5752 70 70 return suite 71 71 72 def run_tests(module_list, verbosity=1, extra_tests=[]):72 def run_tests(module_list, verbosity=1, interactive=True, extra_tests=[]): 73 73 """ 74 74 Run the unit tests for all the modules in the provided list. … … 92 92 93 93 old_name = settings.DATABASE_NAME 94 create_test_db(verbosity )94 create_test_db(verbosity, autoclobber=not interactive) 95 95 result = unittest.TextTestRunner(verbosity=verbosity).run(suite) 96 96 destroy_test_db(old_name, verbosity) django/trunk/docs/testing.txt
r5731 r5752 663 663 ---------------------- 664 664 By convention, a test runner should be called ``run_tests``; however, you 665 can call it anything you want. The only requirement is that it accept t wo665 can call it anything you want. The only requirement is that it accept three 666 666 arguments: 667 667 668 ``run_tests(module_list, verbosity=1 )``668 ``run_tests(module_list, verbosity=1, interactive=True)`` 669 669 The module list is the list of Python modules that contain the models to be 670 670 tested. This is the same format returned by ``django.db.models.get_apps()`` … … 674 674 and ``2`` is verbose output. 675 675 676 **New in Django development version** If ``interactive`` is ``True``, the 677 test suite may ask the user for instructions when the test suite is 678 executed. An example of this behavior would be asking for permission to 679 delete an existing test database. If ``interactive`` is ``False, the 680 test suite must be able to run without any manual intervention. 681 676 682 This method should return the number of tests that failed. 677 683 django/trunk/tests/runtests.py
r5296 r5752 74 74 self.assert_(not missing, "Missing Errors: " + '\n'.join(missing)) 75 75 76 def django_tests(verbosity, tests_to_run):76 def django_tests(verbosity, interactive, tests_to_run): 77 77 from django.conf import settings 78 78 … … 131 131 # Run the test suite, including the extra validation tests. 132 132 from django.test.simple import run_tests 133 failures = run_tests(test_models, verbosity , extra_tests=extra_tests)133 failures = run_tests(test_models, verbosity=verbosity, interactive=interactive, extra_tests=extra_tests) 134 134 if failures: 135 135 sys.exit(failures) … … 150 150 type='choice', choices=['0', '1', '2'], 151 151 help='Verbosity level; 0=minimal output, 1=normal output, 2=all output') 152 parser.add_option('--noinput', action='store_false', dest='interactive', default=True, 153 help='Tells Django to NOT prompt the user for input of any kind.') 152 154 parser.add_option('--settings', 153 155 help='Python path to settings module, e.g. "myproject.settings". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.') … … 158 160 parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. " 159 161 "Set it or use --settings.") 160 django_tests(int(options.verbosity), args)162 django_tests(int(options.verbosity), options.interactive, args)
