Refs #31621 -- Fixed handling --parallel option in test management command and runtests.py.

Regression in ae89daf46f.
Thanks Tim Graham for the report.
This commit is contained in:
Mariusz Felisiak 2021-08-04 10:49:30 +02:00
parent c2a5735d86
commit 36714be874
6 changed files with 72 additions and 47 deletions

View file

@ -434,6 +434,12 @@ class ManageCommandParallelTests(SimpleTestCase):
)
self.assertEqual(stderr.getvalue(), '')
@mock.patch.dict(os.environ, {'DJANGO_TEST_PROCESSES': '7'})
def test_no_parallel_django_test_processes_env(self, *mocked_objects):
with captured_stderr() as stderr:
call_command('test', testrunner='test_runner.tests.MockTestRunner')
self.assertEqual(stderr.getvalue(), '')
@mock.patch.dict(os.environ, {'DJANGO_TEST_PROCESSES': 'invalid'})
def test_django_test_processes_env_non_int(self, *mocked_objects):
with self.assertRaises(ValueError):
@ -443,6 +449,18 @@ class ManageCommandParallelTests(SimpleTestCase):
testrunner='test_runner.tests.MockTestRunner',
)
@mock.patch.dict(os.environ, {'DJANGO_TEST_PROCESSES': '7'})
def test_django_test_processes_parallel_default(self, *mocked_objects):
for parallel in ['--parallel', '--parallel=auto']:
with self.subTest(parallel=parallel):
with captured_stderr() as stderr:
call_command(
'test',
parallel,
testrunner='test_runner.tests.MockTestRunner',
)
self.assertIn('parallel=7', stderr.getvalue())
class CustomTestRunnerOptionsSettingsTests(AdminScriptTestCase):
"""