mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #32114 -- Fixed parallel test crash on non-picklable objects in subtests.
This commit is contained in:
committed by
Mariusz Felisiak
parent
a269d8d1d8
commit
c09e8f5fd8
@@ -51,6 +51,13 @@ class SampleFailingSubtest(SimpleTestCase):
|
||||
with self.subTest(index=i):
|
||||
self.assertEqual(i, 1)
|
||||
|
||||
# This method name doesn't begin with "test" to prevent test discovery
|
||||
# from seeing it.
|
||||
def pickle_error_test(self):
|
||||
with self.subTest("TypeError: cannot pickle memoryview object"):
|
||||
self.x = memoryview(b"")
|
||||
self.fail("expected failure")
|
||||
|
||||
|
||||
class RemoteTestResultTest(SimpleTestCase):
|
||||
def _test_error_exc_info(self):
|
||||
@@ -106,6 +113,16 @@ class RemoteTestResultTest(SimpleTestCase):
|
||||
with self.assertRaisesMessage(TypeError, msg):
|
||||
result._confirm_picklable(not_unpicklable_error)
|
||||
|
||||
def test_unpicklable_subtest(self):
|
||||
result = RemoteTestResult()
|
||||
subtest_test = SampleFailingSubtest(methodName="pickle_error_test")
|
||||
subtest_test.run(result=result)
|
||||
|
||||
events = result.events
|
||||
subtest_event = events[1]
|
||||
assertion_error = subtest_event[3]
|
||||
self.assertEqual(str(assertion_error[1]), "expected failure")
|
||||
|
||||
@unittest.skipUnless(tblib is not None, "requires tblib to be installed")
|
||||
def test_add_failing_subtests(self):
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user