mirror of
https://github.com/django/django.git
synced 2025-10-09 06:49:12 +00:00
[6.0.x] 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> Backport of be581ff473e8ade6365975db2df602f295a4cb4b from main.
This commit is contained in:
parent
db2f206ee1
commit
f8e91d0104
@ -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:
|
||||
|
@ -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])
|
||||
|
Loading…
x
Reference in New Issue
Block a user