summaryrefslogtreecommitdiff
path: root/tests/runtests.py
diff options
context:
space:
mode:
authorChris Jerdonek <chris.jerdonek@gmail.com>2021-04-24 16:46:16 -0700
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2021-07-08 07:29:04 +0200
commit90ba716bf060ee7fef79dc230b0b20644839069f (patch)
tree93ac388d4c3a75e5ab34edbf5a552305b72962d4 /tests/runtests.py
parent77b88fe621bb7828535a4c4cf37d9d4ac01b146b (diff)
downloaddjango-90ba716bf060ee7fef79dc230b0b20644839069f.tar.gz
Fixed #24522 -- Added a --shuffle option to DiscoverRunner.
Diffstat (limited to 'tests/runtests.py')
-rwxr-xr-xtests/runtests.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/runtests.py b/tests/runtests.py
index 2a9adbbc70..648ac27e05 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -353,7 +353,7 @@ class ActionSelenium(argparse.Action):
def django_tests(verbosity, interactive, failfast, keepdb, reverse,
test_labels, debug_sql, parallel, tags, exclude_tags,
test_name_patterns, start_at, start_after, pdb, buffer,
- timing):
+ timing, shuffle):
if verbosity >= 1:
msg = "Testing against Django installed in '%s'" % os.path.dirname(django.__file__)
max_parallel = default_test_processes() if parallel == 0 else parallel
@@ -380,6 +380,7 @@ def django_tests(verbosity, interactive, failfast, keepdb, reverse,
pdb=pdb,
buffer=buffer,
timing=timing,
+ shuffle=shuffle,
)
failures = test_runner.run_tests(test_labels)
teardown_run_tests(state)
@@ -406,6 +407,11 @@ def get_subprocess_args(options):
subprocess_args.append('--tag=%s' % options.tags)
if options.exclude_tags:
subprocess_args.append('--exclude_tag=%s' % options.exclude_tags)
+ if options.shuffle is not False:
+ if options.shuffle is None:
+ subprocess_args.append('--shuffle')
+ else:
+ subprocess_args.append('--shuffle=%s' % options.shuffle)
return subprocess_args
@@ -524,6 +530,13 @@ if __name__ == "__main__":
help='Run the test suite in pairs with the named test to find problem pairs.',
)
parser.add_argument(
+ '--shuffle', nargs='?', default=False, type=int, metavar='SEED',
+ help=(
+ 'Shuffle the order of test cases to help check that tests are '
+ 'properly isolated.'
+ ),
+ )
+ parser.add_argument(
'--reverse', action='store_true',
help='Sort test suites and test cases in opposite order to debug '
'test side effects not apparent with normal execution lineup.',
@@ -650,7 +663,7 @@ if __name__ == "__main__":
options.exclude_tags,
getattr(options, 'test_name_patterns', None),
options.start_at, options.start_after, options.pdb, options.buffer,
- options.timing,
+ options.timing, options.shuffle,
)
time_keeper.print_results()
if failures: