mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #31621 -- Added support for '--parallel auto' to test management command.
This commit is contained in:
committed by
Mariusz Felisiak
parent
7e38a8d66f
commit
ae89daf46f
@@ -50,16 +50,31 @@ class DiscoverRunnerParallelArgumentTests(SimpleTestCase):
|
||||
|
||||
def test_parallel_default(self, *mocked_objects):
|
||||
result = self.get_parser().parse_args([])
|
||||
self.assertEqual(result.parallel, 1)
|
||||
self.assertEqual(result.parallel, 0)
|
||||
|
||||
def test_parallel_flag(self, *mocked_objects):
|
||||
result = self.get_parser().parse_args(['--parallel'])
|
||||
self.assertEqual(result.parallel, 12)
|
||||
|
||||
def test_parallel_auto(self, *mocked_objects):
|
||||
result = self.get_parser().parse_args(['--parallel', 'auto'])
|
||||
self.assertEqual(result.parallel, 12)
|
||||
|
||||
def test_parallel_count(self, *mocked_objects):
|
||||
result = self.get_parser().parse_args(['--parallel', '17'])
|
||||
self.assertEqual(result.parallel, 17)
|
||||
|
||||
def test_parallel_invalid(self, *mocked_objects):
|
||||
with self.assertRaises(SystemExit), captured_stderr() as stderr:
|
||||
self.get_parser().parse_args(['--parallel', 'unaccepted'])
|
||||
msg = "argument --parallel: 'unaccepted' is not an integer or the string 'auto'"
|
||||
self.assertIn(msg, stderr.getvalue())
|
||||
|
||||
@mock.patch.dict(os.environ, {'DJANGO_TEST_PROCESSES': '7'})
|
||||
def test_parallel_env_var(self, *mocked_objects):
|
||||
result = self.get_parser().parse_args([])
|
||||
self.assertEqual(result.parallel, 7)
|
||||
|
||||
@mock.patch.dict(os.environ, {'DJANGO_TEST_PROCESSES': 'typo'})
|
||||
def test_parallel_env_var_non_int(self, *mocked_objects):
|
||||
with self.assertRaises(ValueError):
|
||||
|
||||
Reference in New Issue
Block a user