1
0
mirror of https://github.com/django/django.git synced 2025-10-09 14:59:24 +00:00

Fixed #36491 -- Fixed crash in ParallelTestRunner with --buffer.

Thanks Javier Buzzi and Adam Johnson for reviews.

Co-authored-by: Simon Charette <charette.s@gmail.com>
This commit is contained in:
Shubham Singh 2025-09-12 14:32:35 -05:00 committed by Jacob Walls
parent 1cb76b90e8
commit be581ff473
2 changed files with 27 additions and 0 deletions

View File

@ -566,6 +566,9 @@ class ParallelTestSuite(unittest.TestSuite):
(self.runner_class, index, subsuite, self.failfast, self.buffer)
for index, subsuite in enumerate(self.subsuites)
]
# Don't buffer in the main process to avoid error propagation issues.
result.buffer = False
test_results = pool.imap_unordered(self.run_subsuite.__func__, args)
while True:

View File

@ -282,3 +282,27 @@ class ParallelTestSuiteTest(SimpleTestCase):
self.assertEqual(len(result.errors), 0)
self.assertEqual(len(result.failures), 0)
def test_buffer_mode_reports_setupclass_failure(self):
test = SampleErrorTest("dummy_test")
remote_result = RemoteTestResult()
suite = TestSuite([test])
suite.run(remote_result)
pts = ParallelTestSuite([suite], processes=2, buffer=True)
pts.serialized_aliases = set()
test_result = TestResult()
test_result.buffer = True
with unittest.mock.patch("multiprocessing.Pool") as mock_pool:
def fake_next(*args, **kwargs):
test_result.shouldStop = True
return (0, remote_result.events)
mock_pool.return_value.imap_unordered.return_value = unittest.mock.Mock(
next=fake_next
)
pts.run(test_result)
self.assertIn("ValueError: woops", test_result.errors[0][1])