File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed
Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -833,7 +833,7 @@ class ExternalEntityParserCreateErrorTest(unittest.TestCase):
833833
834834 @classmethod
835835 def setUpClass (cls ):
836- cls ._testcapi = import_helper .import_module ('_testcapi' )
836+ cls .testcapi = import_helper .import_module ('_testcapi' )
837837
838838 def test_error_path_no_crash (self ):
839839 # When an allocation inside ExternalEntityParserCreate fails,
@@ -844,14 +844,17 @@ def test_error_path_no_crash(self):
844844 parser .buffer_text = True
845845 rc_before = sys .getrefcount (parser )
846846
847- self ._testcapi .set_nomemory (1 , 10 )
847+ # We avoid self.assertRaises(MemoryError) here because the
848+ # context manager itself needs memory allocations that fail
849+ # while the nomemory hook is active.
850+ self .testcapi .set_nomemory (1 , 10 )
848851 raised = False
849852 try :
850853 parser .ExternalEntityParserCreate (None )
851854 except MemoryError :
852855 raised = True
853856 finally :
854- self ._testcapi .remove_mem_hooks ()
857+ self .testcapi .remove_mem_hooks ()
855858 self .assertTrue (raised , "MemoryError not raised" )
856859
857860 rc_after = sys .getrefcount (parser )
You can’t perform that action at this time.
0 commit comments