mirror of
https://github.com/django/django.git
synced 2025-07-24 13:44:32 +00:00
Fixed #2879 -- Added support for the integration with Selenium and other in-browser testing frameworks. Also added the first Selenium tests for contrib.admin
. Many thanks to everyone for their contributions and feedback: Mikeal Rogers, Dirk Datzert, mir, Simon G., Almad, Russell Keith-Magee, Denis Golomazov, devin, robertrv, andrewbadr, Idan Gazit, voidspace, Tom Christie, hjwp2, Adam Nelson, Jannis Leidel, Anssi Kääriäinen, Preston Holmes, Bruno Renié and Jacob Kaplan-Moss.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17241 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
parent
45e3dff5ac
commit
2f02a05ffb
21 changed files with 921 additions and 46 deletions
|
@ -49,7 +49,10 @@ def geodjango(settings):
|
|||
|
||||
def get_test_modules():
|
||||
modules = []
|
||||
for loc, dirpath in (MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR), (REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR), (CONTRIB_DIR_NAME, CONTRIB_DIR):
|
||||
for loc, dirpath in (
|
||||
(MODEL_TESTS_DIR_NAME, MODEL_TEST_DIR),
|
||||
(REGRESSION_TESTS_DIR_NAME, REGRESSION_TEST_DIR),
|
||||
(CONTRIB_DIR_NAME, CONTRIB_DIR)):
|
||||
for f in os.listdir(dirpath):
|
||||
if (f.startswith('__init__') or
|
||||
f.startswith('.') or
|
||||
|
@ -150,7 +153,8 @@ def django_tests(verbosity, interactive, failfast, test_labels):
|
|||
settings.TEST_RUNNER = 'django.test.simple.DjangoTestSuiteRunner'
|
||||
TestRunner = get_runner(settings)
|
||||
|
||||
test_runner = TestRunner(verbosity=verbosity, interactive=interactive, failfast=failfast)
|
||||
test_runner = TestRunner(verbosity=verbosity, interactive=interactive,
|
||||
failfast=failfast)
|
||||
failures = test_runner.run_tests(test_labels, extra_tests=extra_tests)
|
||||
|
||||
teardown(state)
|
||||
|
@ -175,7 +179,8 @@ def bisect_tests(bisection_label, options, test_labels):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
subprocess_args = [sys.executable, __file__, '--settings=%s' % options.settings]
|
||||
subprocess_args = [
|
||||
sys.executable, __file__, '--settings=%s' % options.settings]
|
||||
if options.failfast:
|
||||
subprocess_args.append('--failfast')
|
||||
if options.verbosity:
|
||||
|
@ -235,7 +240,8 @@ def paired_tests(paired_test, options, test_labels):
|
|||
except ValueError:
|
||||
pass
|
||||
|
||||
subprocess_args = [sys.executable, __file__, '--settings=%s' % options.settings]
|
||||
subprocess_args = [
|
||||
sys.executable, __file__, '--settings=%s' % options.settings]
|
||||
if options.failfast:
|
||||
subprocess_args.append('--failfast')
|
||||
if options.verbosity:
|
||||
|
@ -244,7 +250,8 @@ def paired_tests(paired_test, options, test_labels):
|
|||
subprocess_args.append('--noinput')
|
||||
|
||||
for i, label in enumerate(test_labels):
|
||||
print '***** %d of %d: Check test pairing with %s' % (i+1, len(test_labels), label)
|
||||
print '***** %d of %d: Check test pairing with %s' % (
|
||||
i+1, len(test_labels), label)
|
||||
failures = subprocess.call(subprocess_args + [label, paired_test])
|
||||
if failures:
|
||||
print '***** Found problem pair with',label
|
||||
|
@ -257,19 +264,36 @@ if __name__ == "__main__":
|
|||
from optparse import OptionParser
|
||||
usage = "%prog [options] [module module module ...]"
|
||||
parser = OptionParser(usage=usage)
|
||||
parser.add_option('-v','--verbosity', action='store', dest='verbosity', default='1',
|
||||
parser.add_option(
|
||||
'-v','--verbosity', action='store', dest='verbosity', default='1',
|
||||
type='choice', choices=['0', '1', '2', '3'],
|
||||
help='Verbosity level; 0=minimal output, 1=normal output, 2=all output')
|
||||
parser.add_option('--noinput', action='store_false', dest='interactive', default=True,
|
||||
help='Verbosity level; 0=minimal output, 1=normal output, 2=all '
|
||||
'output')
|
||||
parser.add_option(
|
||||
'--noinput', action='store_false', dest='interactive', default=True,
|
||||
help='Tells Django to NOT prompt the user for input of any kind.')
|
||||
parser.add_option('--failfast', action='store_true', dest='failfast', default=False,
|
||||
help='Tells Django to stop running the test suite after first failed test.')
|
||||
parser.add_option('--settings',
|
||||
help='Python path to settings module, e.g. "myproject.settings". If this isn\'t provided, the DJANGO_SETTINGS_MODULE environment variable will be used.')
|
||||
parser.add_option('--bisect', action='store', dest='bisect', default=None,
|
||||
help="Bisect the test suite to discover a test that causes a test failure when combined with the named test.")
|
||||
parser.add_option('--pair', action='store', dest='pair', default=None,
|
||||
help="Run the test suite in pairs with the named test to find problem pairs.")
|
||||
parser.add_option(
|
||||
'--failfast', action='store_true', dest='failfast', default=False,
|
||||
help='Tells Django to stop running the test suite after first failed '
|
||||
'test.')
|
||||
parser.add_option(
|
||||
'--settings',
|
||||
help='Python path to settings module, e.g. "myproject.settings". If '
|
||||
'this isn\'t provided, the DJANGO_SETTINGS_MODULE environment '
|
||||
'variable will be used.')
|
||||
parser.add_option(
|
||||
'--bisect', action='store', dest='bisect', default=None,
|
||||
help='Bisect the test suite to discover a test that causes a test '
|
||||
'failure when combined with the named test.')
|
||||
parser.add_option(
|
||||
'--pair', action='store', dest='pair', default=None,
|
||||
help='Run the test suite in pairs with the named test to find problem '
|
||||
'pairs.')
|
||||
parser.add_option(
|
||||
'--liveserver', action='store', dest='liveserver', default=None,
|
||||
help='Overrides the default address where the live server (used with '
|
||||
'LiveServerTestCase) is expected to run from. The default value '
|
||||
'is localhost:8081.'),
|
||||
options, args = parser.parse_args()
|
||||
if options.settings:
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
|
||||
|
@ -279,11 +303,15 @@ if __name__ == "__main__":
|
|||
else:
|
||||
options.settings = os.environ['DJANGO_SETTINGS_MODULE']
|
||||
|
||||
if options.liveserver is not None:
|
||||
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options.liveserver
|
||||
|
||||
if options.bisect:
|
||||
bisect_tests(options.bisect, options, args)
|
||||
elif options.pair:
|
||||
paired_tests(options.pair, options, args)
|
||||
else:
|
||||
failures = django_tests(int(options.verbosity), options.interactive, options.failfast, args)
|
||||
failures = django_tests(int(options.verbosity), options.interactive,
|
||||
options.failfast, args)
|
||||
if failures:
|
||||
sys.exit(bool(failures))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue