2005-07-29 15:15:40 +00:00
|
|
|
#!/usr/bin/env python
|
2013-03-25 04:34:46 +00:00
|
|
|
import logging
|
2011-08-12 08:43:52 +00:00
|
|
|
import os
|
|
|
|
import shutil
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
import tempfile
|
2005-07-29 15:15:40 +00:00
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
from django import contrib
|
2012-12-08 10:13:52 +00:00
|
|
|
from django.utils._os import upath
|
2012-07-20 12:48:51 +00:00
|
|
|
from django.utils import six
|
2011-10-13 21:34:56 +00:00
|
|
|
|
2013-05-11 03:08:45 +00:00
|
|
|
CONTRIB_MODULE_PATH = 'django.contrib'
|
2007-05-20 03:51:21 +00:00
|
|
|
|
2006-09-02 09:34:40 +00:00
|
|
|
TEST_TEMPLATE_DIR = 'templates'
|
2005-07-29 15:15:40 +00:00
|
|
|
|
2013-02-26 14:20:37 +00:00
|
|
|
RUNTESTS_DIR = os.path.abspath(os.path.dirname(upath(__file__)))
|
2012-12-08 10:13:52 +00:00
|
|
|
CONTRIB_DIR = os.path.dirname(upath(contrib.__file__))
|
2013-05-11 03:08:45 +00:00
|
|
|
|
2011-08-12 08:43:52 +00:00
|
|
|
TEMP_DIR = tempfile.mkdtemp(prefix='django_')
|
2011-11-13 19:05:02 +00:00
|
|
|
os.environ['DJANGO_TEST_TEMP_DIR'] = TEMP_DIR
|
2005-07-29 22:35:54 +00:00
|
|
|
|
2013-05-11 03:08:45 +00:00
|
|
|
SUBDIRS_TO_SKIP = [
|
|
|
|
'templates',
|
|
|
|
'test_discovery_sample',
|
|
|
|
'test_discovery_sample2',
|
|
|
|
'test_runner_deprecation_app',
|
|
|
|
'test_runner_invalid_app',
|
|
|
|
]
|
2010-04-14 18:17:44 +00:00
|
|
|
|
2006-05-26 21:28:12 +00:00
|
|
|
ALWAYS_INSTALLED_APPS = [
|
2013-03-13 17:30:48 +00:00
|
|
|
'shared_models',
|
2006-05-26 21:28:12 +00:00
|
|
|
'django.contrib.contenttypes',
|
2006-06-20 14:27:44 +00:00
|
|
|
'django.contrib.auth',
|
2007-08-15 11:25:22 +00:00
|
|
|
'django.contrib.sites',
|
2006-05-26 21:28:12 +00:00
|
|
|
'django.contrib.flatpages',
|
|
|
|
'django.contrib.redirects',
|
|
|
|
'django.contrib.sessions',
|
2009-12-09 16:57:23 +00:00
|
|
|
'django.contrib.messages',
|
2006-06-16 18:58:45 +00:00
|
|
|
'django.contrib.comments',
|
|
|
|
'django.contrib.admin',
|
2010-08-14 13:41:56 +00:00
|
|
|
'django.contrib.admindocs',
|
2010-10-20 01:33:24 +00:00
|
|
|
'django.contrib.staticfiles',
|
2011-05-06 13:29:58 +00:00
|
|
|
'django.contrib.humanize',
|
2013-02-26 08:57:29 +00:00
|
|
|
'staticfiles_tests',
|
|
|
|
'staticfiles_tests.apps.test',
|
|
|
|
'staticfiles_tests.apps.no_label',
|
2006-05-26 21:28:12 +00:00
|
|
|
]
|
|
|
|
|
2010-12-21 23:42:12 +00:00
|
|
|
|
2011-01-21 15:55:27 +00:00
|
|
|
def get_test_modules():
|
|
|
|
modules = []
|
2013-05-11 03:08:45 +00:00
|
|
|
for modpath, dirpath in (
|
2013-02-26 08:57:29 +00:00
|
|
|
(None, RUNTESTS_DIR),
|
2013-05-11 03:08:45 +00:00
|
|
|
(CONTRIB_MODULE_PATH, CONTRIB_DIR)):
|
2006-06-20 14:27:44 +00:00
|
|
|
for f in os.listdir(dirpath):
|
2013-02-26 08:57:29 +00:00
|
|
|
if ('.' in f or
|
2012-05-05 14:45:02 +00:00
|
|
|
# Python 3 byte code dirs (PEP 3147)
|
2012-05-05 12:01:38 +00:00
|
|
|
f == '__pycache__' or
|
2011-08-23 04:25:07 +00:00
|
|
|
f.startswith('sql') or
|
2013-02-26 12:19:18 +00:00
|
|
|
os.path.basename(f) in SUBDIRS_TO_SKIP or
|
|
|
|
os.path.isfile(f)):
|
2006-06-20 07:12:45 +00:00
|
|
|
continue
|
2013-05-11 03:08:45 +00:00
|
|
|
modules.append((modpath, f))
|
2011-01-21 15:55:27 +00:00
|
|
|
return modules
|
2005-07-29 22:35:54 +00:00
|
|
|
|
2013-05-11 03:08:45 +00:00
|
|
|
def get_installed():
|
|
|
|
from django.db.models.loading import get_apps
|
|
|
|
return [app.__name__.rsplit('.', 1)[0] for app in get_apps()]
|
|
|
|
|
|
|
|
|
2010-10-09 14:44:54 +00:00
|
|
|
def setup(verbosity, test_labels):
|
2006-08-27 13:59:47 +00:00
|
|
|
from django.conf import settings
|
2013-03-11 15:59:59 +00:00
|
|
|
from django.db.models.loading import get_apps, load_app
|
2010-10-09 14:44:54 +00:00
|
|
|
state = {
|
|
|
|
'INSTALLED_APPS': settings.INSTALLED_APPS,
|
|
|
|
'ROOT_URLCONF': getattr(settings, "ROOT_URLCONF", ""),
|
|
|
|
'TEMPLATE_DIRS': settings.TEMPLATE_DIRS,
|
|
|
|
'LANGUAGE_CODE': settings.LANGUAGE_CODE,
|
2011-06-30 09:06:19 +00:00
|
|
|
'STATIC_URL': settings.STATIC_URL,
|
2011-08-12 08:43:52 +00:00
|
|
|
'STATIC_ROOT': settings.STATIC_ROOT,
|
2010-10-09 14:44:54 +00:00
|
|
|
}
|
2006-12-15 06:06:52 +00:00
|
|
|
|
2007-02-10 04:01:19 +00:00
|
|
|
# Redirect some settings for the duration of these tests.
|
2006-08-27 13:59:47 +00:00
|
|
|
settings.INSTALLED_APPS = ALWAYS_INSTALLED_APPS
|
2006-09-02 09:34:40 +00:00
|
|
|
settings.ROOT_URLCONF = 'urls'
|
2011-06-30 09:06:19 +00:00
|
|
|
settings.STATIC_URL = '/static/'
|
2011-08-12 08:43:52 +00:00
|
|
|
settings.STATIC_ROOT = os.path.join(TEMP_DIR, 'static')
|
|
|
|
settings.TEMPLATE_DIRS = (os.path.join(RUNTESTS_DIR, TEST_TEMPLATE_DIR),)
|
2007-10-21 17:26:32 +00:00
|
|
|
settings.LANGUAGE_CODE = 'en'
|
2007-12-01 21:58:51 +00:00
|
|
|
settings.SITE_ID = 1
|
2006-12-15 06:06:52 +00:00
|
|
|
|
2013-03-25 04:34:46 +00:00
|
|
|
if verbosity > 0:
|
|
|
|
# Ensure any warnings captured to logging are piped through a verbose
|
|
|
|
# logging handler. If any -W options were passed explicitly on command
|
|
|
|
# line, warnings are not captured, and this has no effect.
|
|
|
|
logger = logging.getLogger('py.warnings')
|
|
|
|
handler = logging.StreamHandler()
|
|
|
|
logger.addHandler(handler)
|
|
|
|
|
2006-12-15 06:06:52 +00:00
|
|
|
# Load all the ALWAYS_INSTALLED_APPS.
|
2006-08-27 13:59:47 +00:00
|
|
|
get_apps()
|
2006-12-15 06:06:52 +00:00
|
|
|
|
2007-02-10 04:01:19 +00:00
|
|
|
# Load all the test model apps.
|
2011-01-21 15:55:27 +00:00
|
|
|
test_modules = get_test_modules()
|
2010-12-21 23:42:12 +00:00
|
|
|
|
2013-05-11 03:08:45 +00:00
|
|
|
# Reduce given test labels to just the app module path
|
|
|
|
test_labels_set = set()
|
|
|
|
for label in test_labels:
|
|
|
|
bits = label.split('.')
|
|
|
|
if bits[:2] == ['django', 'contrib']:
|
|
|
|
bits = bits[:3]
|
|
|
|
else:
|
|
|
|
bits = bits[:1]
|
|
|
|
test_labels_set.add('.'.join(bits))
|
|
|
|
|
2010-12-21 23:42:12 +00:00
|
|
|
# If GeoDjango, then we'll want to add in the test applications
|
|
|
|
# that are a part of its test suite.
|
2013-05-11 03:08:45 +00:00
|
|
|
from django.contrib.gis.tests.utils import HAS_SPATIAL_DB
|
|
|
|
if HAS_SPATIAL_DB:
|
2010-12-21 23:42:12 +00:00
|
|
|
from django.contrib.gis.tests import geo_apps
|
2013-05-11 03:08:45 +00:00
|
|
|
test_modules.extend(geo_apps())
|
2012-03-17 04:39:23 +00:00
|
|
|
settings.INSTALLED_APPS.extend(['django.contrib.gis', 'django.contrib.sitemaps'])
|
2011-01-21 15:55:27 +00:00
|
|
|
|
2013-05-11 03:08:45 +00:00
|
|
|
for modpath, module_name in test_modules:
|
|
|
|
if modpath:
|
|
|
|
module_label = '.'.join([modpath, module_name])
|
2013-02-26 08:57:29 +00:00
|
|
|
else:
|
|
|
|
module_label = module_name
|
2013-05-11 03:08:45 +00:00
|
|
|
# if the module (or an ancestor) was named on the command line, or
|
2011-01-21 15:55:27 +00:00
|
|
|
# no modules were named (i.e., run all), import
|
2013-05-11 03:08:45 +00:00
|
|
|
# this module and add it to INSTALLED_APPS.
|
|
|
|
if not test_labels:
|
|
|
|
module_found_in_labels = True
|
|
|
|
else:
|
|
|
|
match = lambda label: (
|
|
|
|
module_label == label or # exact match
|
|
|
|
module_label.startswith(label + '.') # ancestor match
|
|
|
|
)
|
|
|
|
|
|
|
|
module_found_in_labels = any(match(l) for l in test_labels_set)
|
|
|
|
|
|
|
|
if module_found_in_labels:
|
2010-08-20 15:03:11 +00:00
|
|
|
if verbosity >= 2:
|
2012-04-28 16:02:01 +00:00
|
|
|
print("Importing application %s" % module_name)
|
2011-01-21 15:55:27 +00:00
|
|
|
mod = load_app(module_label)
|
2010-08-20 15:03:11 +00:00
|
|
|
if mod:
|
2011-01-21 15:55:27 +00:00
|
|
|
if module_label not in settings.INSTALLED_APPS:
|
|
|
|
settings.INSTALLED_APPS.append(module_label)
|
2006-08-27 13:59:47 +00:00
|
|
|
|
2010-10-09 14:44:54 +00:00
|
|
|
return state
|
|
|
|
|
|
|
|
def teardown(state):
|
|
|
|
from django.conf import settings
|
2011-12-25 18:53:29 +00:00
|
|
|
# Removing the temporary TEMP_DIR. Ensure we pass in unicode
|
|
|
|
# so that it will successfully remove temp trees containing
|
|
|
|
# non-ASCII filenames on Windows. (We're assuming the temp dir
|
|
|
|
# name itself does not contain non-ASCII characters.)
|
2012-07-20 12:48:51 +00:00
|
|
|
shutil.rmtree(six.text_type(TEMP_DIR))
|
2010-10-09 14:44:54 +00:00
|
|
|
# Restore the old settings.
|
|
|
|
for key, value in state.items():
|
|
|
|
setattr(settings, key, value)
|
|
|
|
|
|
|
|
def django_tests(verbosity, interactive, failfast, test_labels):
|
|
|
|
from django.conf import settings
|
|
|
|
state = setup(verbosity, test_labels)
|
2006-08-27 13:59:47 +00:00
|
|
|
extra_tests = []
|
2008-10-02 12:57:13 +00:00
|
|
|
|
2006-08-27 13:59:47 +00:00
|
|
|
# Run the test suite, including the extra validation tests.
|
2013-05-11 13:47:40 +00:00
|
|
|
from django.test.utils import get_runner
|
|
|
|
if not hasattr(settings, 'TEST_RUNNER'):
|
|
|
|
settings.TEST_RUNNER = 'django.test.runner.DiscoverRunner'
|
|
|
|
TestRunner = get_runner(settings)
|
2010-01-18 15:11:01 +00:00
|
|
|
|
2013-05-11 13:47:40 +00:00
|
|
|
test_runner = TestRunner(
|
2013-05-11 03:08:45 +00:00
|
|
|
verbosity=verbosity,
|
|
|
|
interactive=interactive,
|
|
|
|
failfast=failfast,
|
|
|
|
)
|
|
|
|
failures = test_runner.run_tests(
|
|
|
|
test_labels or get_installed(), extra_tests=extra_tests)
|
2009-02-28 04:46:38 +00:00
|
|
|
|
2010-10-09 14:44:54 +00:00
|
|
|
teardown(state)
|
|
|
|
return failures
|
2006-12-15 06:06:52 +00:00
|
|
|
|
2010-10-09 14:44:54 +00:00
|
|
|
|
|
|
|
def bisect_tests(bisection_label, options, test_labels):
|
|
|
|
state = setup(int(options.verbosity), test_labels)
|
|
|
|
|
2013-05-11 03:08:45 +00:00
|
|
|
test_labels = test_labels or get_installed()
|
2010-10-09 14:44:54 +00:00
|
|
|
|
2012-04-28 16:02:01 +00:00
|
|
|
print('***** Bisecting test suite: %s' % ' '.join(test_labels))
|
2010-10-09 14:44:54 +00:00
|
|
|
|
|
|
|
# Make sure the bisection point isn't in the test list
|
|
|
|
# Also remove tests that need to be run in specific combinations
|
|
|
|
for label in [bisection_label, 'model_inheritance_same_model_name']:
|
|
|
|
try:
|
|
|
|
test_labels.remove(label)
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
|
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
2011-12-22 08:33:58 +00:00
|
|
|
subprocess_args = [
|
2012-12-08 10:13:52 +00:00
|
|
|
sys.executable, upath(__file__), '--settings=%s' % options.settings]
|
2010-10-09 14:44:54 +00:00
|
|
|
if options.failfast:
|
|
|
|
subprocess_args.append('--failfast')
|
|
|
|
if options.verbosity:
|
|
|
|
subprocess_args.append('--verbosity=%s' % options.verbosity)
|
|
|
|
if not options.interactive:
|
|
|
|
subprocess_args.append('--noinput')
|
|
|
|
|
|
|
|
iteration = 1
|
|
|
|
while len(test_labels) > 1:
|
|
|
|
midpoint = len(test_labels)/2
|
|
|
|
test_labels_a = test_labels[:midpoint] + [bisection_label]
|
|
|
|
test_labels_b = test_labels[midpoint:] + [bisection_label]
|
2012-04-28 16:02:01 +00:00
|
|
|
print('***** Pass %da: Running the first half of the test suite' % iteration)
|
|
|
|
print('***** Test labels: %s' % ' '.join(test_labels_a))
|
2010-10-09 14:44:54 +00:00
|
|
|
failures_a = subprocess.call(subprocess_args + test_labels_a)
|
|
|
|
|
2012-04-28 16:02:01 +00:00
|
|
|
print('***** Pass %db: Running the second half of the test suite' % iteration)
|
|
|
|
print('***** Test labels: %s' % ' '.join(test_labels_b))
|
|
|
|
print('')
|
2010-10-09 14:44:54 +00:00
|
|
|
failures_b = subprocess.call(subprocess_args + test_labels_b)
|
|
|
|
|
|
|
|
if failures_a and not failures_b:
|
2012-04-28 16:02:01 +00:00
|
|
|
print("***** Problem found in first half. Bisecting again...")
|
2010-10-09 14:44:54 +00:00
|
|
|
iteration = iteration + 1
|
|
|
|
test_labels = test_labels_a[:-1]
|
|
|
|
elif failures_b and not failures_a:
|
2012-04-28 16:02:01 +00:00
|
|
|
print("***** Problem found in second half. Bisecting again...")
|
2010-10-09 14:44:54 +00:00
|
|
|
iteration = iteration + 1
|
|
|
|
test_labels = test_labels_b[:-1]
|
|
|
|
elif failures_a and failures_b:
|
2012-04-28 16:02:01 +00:00
|
|
|
print("***** Multiple sources of failure found")
|
2010-10-09 14:44:54 +00:00
|
|
|
break
|
|
|
|
else:
|
2012-04-28 16:02:01 +00:00
|
|
|
print("***** No source of failure found... try pair execution (--pair)")
|
2010-10-09 14:44:54 +00:00
|
|
|
break
|
|
|
|
|
|
|
|
if len(test_labels) == 1:
|
2012-04-28 16:02:01 +00:00
|
|
|
print("***** Source of error: %s" % test_labels[0])
|
2010-10-09 14:44:54 +00:00
|
|
|
teardown(state)
|
|
|
|
|
|
|
|
def paired_tests(paired_test, options, test_labels):
|
|
|
|
state = setup(int(options.verbosity), test_labels)
|
|
|
|
|
2013-05-11 03:08:45 +00:00
|
|
|
test_labels = test_labels or get_installed()
|
2010-10-09 14:44:54 +00:00
|
|
|
|
2012-04-28 16:02:01 +00:00
|
|
|
print('***** Trying paired execution')
|
2010-10-09 14:44:54 +00:00
|
|
|
|
2010-10-11 12:55:17 +00:00
|
|
|
# Make sure the constant member of the pair isn't in the test list
|
2010-10-09 14:44:54 +00:00
|
|
|
# Also remove tests that need to be run in specific combinations
|
|
|
|
for label in [paired_test, 'model_inheritance_same_model_name']:
|
|
|
|
try:
|
|
|
|
test_labels.remove(label)
|
|
|
|
except ValueError:
|
|
|
|
pass
|
|
|
|
|
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
2011-12-22 08:33:58 +00:00
|
|
|
subprocess_args = [
|
2012-12-08 10:13:52 +00:00
|
|
|
sys.executable, upath(__file__), '--settings=%s' % options.settings]
|
2010-10-09 14:44:54 +00:00
|
|
|
if options.failfast:
|
|
|
|
subprocess_args.append('--failfast')
|
|
|
|
if options.verbosity:
|
|
|
|
subprocess_args.append('--verbosity=%s' % options.verbosity)
|
|
|
|
if not options.interactive:
|
|
|
|
subprocess_args.append('--noinput')
|
|
|
|
|
|
|
|
for i, label in enumerate(test_labels):
|
2012-04-28 16:02:01 +00:00
|
|
|
print('***** %d of %d: Check test pairing with %s' % (
|
|
|
|
i + 1, len(test_labels), label))
|
2010-10-09 14:44:54 +00:00
|
|
|
failures = subprocess.call(subprocess_args + [label, paired_test])
|
|
|
|
if failures:
|
2012-04-28 16:02:01 +00:00
|
|
|
print('***** Found problem pair with %s' % label)
|
2010-10-09 14:44:54 +00:00
|
|
|
return
|
|
|
|
|
2012-04-28 16:02:01 +00:00
|
|
|
print('***** No problem pair found')
|
2010-10-09 14:44:54 +00:00
|
|
|
teardown(state)
|
2006-12-15 06:06:52 +00:00
|
|
|
|
2005-07-29 15:15:40 +00:00
|
|
|
if __name__ == "__main__":
|
|
|
|
from optparse import OptionParser
|
2011-01-21 15:55:27 +00:00
|
|
|
usage = "%prog [options] [module module module ...]"
|
2006-02-18 20:08:20 +00:00
|
|
|
parser = OptionParser(usage=usage)
|
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
2011-12-22 08:33:58 +00:00
|
|
|
parser.add_option(
|
2012-11-04 18:16:06 +00:00
|
|
|
'-v', '--verbosity', action='store', dest='verbosity', default='1',
|
2010-08-07 06:58:14 +00:00
|
|
|
type='choice', choices=['0', '1', '2', '3'],
|
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
2011-12-22 08:33:58 +00:00
|
|
|
help='Verbosity level; 0=minimal output, 1=normal output, 2=all '
|
|
|
|
'output')
|
|
|
|
parser.add_option(
|
|
|
|
'--noinput', action='store_false', dest='interactive', default=True,
|
2007-07-23 12:14:32 +00:00
|
|
|
help='Tells Django to NOT prompt the user for input of any kind.')
|
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
2011-12-22 08:33:58 +00:00
|
|
|
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 '
|
2013-02-23 16:10:48 +00:00
|
|
|
'is localhost:8081.')
|
|
|
|
parser.add_option(
|
2013-02-25 17:14:42 +00:00
|
|
|
'--selenium', action='store_true', dest='selenium',
|
2013-02-23 16:10:48 +00:00
|
|
|
default=False,
|
2013-02-25 17:14:42 +00:00
|
|
|
help='Run the Selenium tests as well (if Selenium is installed)')
|
2005-07-29 15:15:40 +00:00
|
|
|
options, args = parser.parse_args()
|
2005-08-10 15:36:16 +00:00
|
|
|
if options.settings:
|
|
|
|
os.environ['DJANGO_SETTINGS_MODULE'] = options.settings
|
2007-02-26 22:34:56 +00:00
|
|
|
elif "DJANGO_SETTINGS_MODULE" not in os.environ:
|
|
|
|
parser.error("DJANGO_SETTINGS_MODULE is not set in the environment. "
|
|
|
|
"Set it or use --settings.")
|
2011-01-27 00:00:20 +00:00
|
|
|
else:
|
|
|
|
options.settings = os.environ['DJANGO_SETTINGS_MODULE']
|
2010-10-09 14:44:54 +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
2011-12-22 08:33:58 +00:00
|
|
|
if options.liveserver is not None:
|
|
|
|
os.environ['DJANGO_LIVE_TEST_SERVER_ADDRESS'] = options.liveserver
|
|
|
|
|
2013-02-25 17:14:42 +00:00
|
|
|
if options.selenium:
|
|
|
|
os.environ['DJANGO_SELENIUM_TESTS'] = '1'
|
2013-02-23 16:10:48 +00:00
|
|
|
|
2010-10-09 14:44:54 +00:00
|
|
|
if options.bisect:
|
|
|
|
bisect_tests(options.bisect, options, args)
|
|
|
|
elif options.pair:
|
|
|
|
paired_tests(options.pair, options, args)
|
|
|
|
else:
|
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
2011-12-22 08:33:58 +00:00
|
|
|
failures = django_tests(int(options.verbosity), options.interactive,
|
|
|
|
options.failfast, args)
|
2010-10-09 14:44:54 +00:00
|
|
|
if failures:
|
|
|
|
sys.exit(bool(failures))
|