summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAymeric Augustin <aymeric.augustin@m4x.org>2015-02-05 20:31:02 +0100
committerAymeric Augustin <aymeric.augustin@m4x.org>2015-09-09 23:01:10 +0200
commitcd9fcd4e8073490a52c9e79133ada4661cb7db38 (patch)
tree12afd13891c40a6cf367b7ed73f73ba896b2d1bc /tests
parentacb833081dd3abca3bc62753103690f23fb3f0ec (diff)
Implemented a parallel test runner.
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runtests.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/tests/runtests.py b/tests/runtests.py
index 97c09c7372..095a9db8df 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -13,6 +13,7 @@ from django.apps import apps
from django.conf import settings
from django.db import connection
from django.test import TestCase, TransactionTestCase
+from django.test.runner import default_test_processes
from django.test.utils import get_runner
from django.utils import six
from django.utils._os import upath
@@ -93,9 +94,10 @@ def get_installed():
return [app_config.name for app_config in apps.get_app_configs()]
-def setup(verbosity, test_labels):
+def setup(verbosity, test_labels, parallel):
if verbosity >= 1:
- print("Testing against Django installed in '%s'" % os.path.dirname(django.__file__))
+ print("Testing against Django installed in '%s' with %d processes" % (
+ os.path.dirname(django.__file__), parallel))
# Force declaring available_apps in TransactionTestCase for faster tests.
def no_available_apps(self):
@@ -232,8 +234,9 @@ def teardown(state):
setattr(settings, key, value)
-def django_tests(verbosity, interactive, failfast, keepdb, reverse, test_labels, debug_sql):
- state = setup(verbosity, test_labels)
+def django_tests(verbosity, interactive, failfast, keepdb, reverse,
+ test_labels, debug_sql, parallel):
+ state = setup(verbosity, test_labels, parallel)
extra_tests = []
# Run the test suite, including the extra validation tests.
@@ -248,6 +251,7 @@ def django_tests(verbosity, interactive, failfast, keepdb, reverse, test_labels,
keepdb=keepdb,
reverse=reverse,
debug_sql=debug_sql,
+ parallel=parallel,
)
failures = test_runner.run_tests(
test_labels or get_installed(),
@@ -389,10 +393,15 @@ if __name__ == "__main__":
'is localhost:8081.')
parser.add_argument(
'--selenium', action='store_true', dest='selenium', default=False,
- help='Run the Selenium tests as well (if Selenium is installed)')
+ help='Run the Selenium tests as well (if Selenium is installed).')
parser.add_argument(
'--debug-sql', action='store_true', dest='debug_sql', default=False,
- help='Turn on the SQL query logger within tests')
+ help='Turn on the SQL query logger within tests.')
+ parser.add_argument(
+ '--parallel', dest='parallel', nargs='?', default=1, type=int,
+ const=default_test_processes(),
+ help='Run tests in parallel processes.')
+
options = parser.parse_args()
# mock is a required dependency
@@ -429,6 +438,6 @@ if __name__ == "__main__":
failures = django_tests(options.verbosity, options.interactive,
options.failfast, options.keepdb,
options.reverse, options.modules,
- options.debug_sql)
+ options.debug_sql, options.parallel)
if failures:
sys.exit(bool(failures))