diff --git a/docs/ref/django-admin.txt b/docs/ref/django-admin.txt index 110b1e802a..f0d273c73b 100644 --- a/docs/ref/django-admin.txt +++ b/docs/ref/django-admin.txt @@ -1477,7 +1477,7 @@ Using ``--parallel`` without a value, or with the value ``auto``, runs one test process per core according to :func:`multiprocessing.cpu_count()`. You can override this by passing the desired number of processes, e.g. ``--parallel 4``, or by setting the :envvar:`DJANGO_TEST_PROCESSES` environment -variable. +variable. If both are given, then ``--parallel 4`` takes precedence. Django distributes test cases — :class:`unittest.TestCase` subclasses — to subprocesses. If there are fewer test cases than configured processes, Django diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index 28145be3db..1614a164af 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -550,6 +550,16 @@ class ManageCommandParallelTests(SimpleTestCase): ) self.assertIn("parallel=7", stderr.getvalue()) + @mock.patch.dict(os.environ, {"DJANGO_TEST_PROCESSES": "7"}) + def test_django_test_processes_parallel_override_env(self, *mocked_objects): + with captured_stderr() as stderr: + call_command( + "test", + "--parallel=8", + testrunner="test_runner.tests.MockTestRunner", + ) + self.assertIn("parallel=8", stderr.getvalue()) + class CustomTestRunnerOptionsSettingsTests(AdminScriptTestCase): """