code: def test_assertRaises_frames_survival(self):
      # Issue #9815: assertRaises should avoid keeping local variables
      # in a traceback alive.
      class A:
          pass
  
      wr = None
  
      class Foo(unittest.TestCase):
          def foo(self):
              nonlocal wr
              a = A()
              wr = weakref.ref(a)
              try:
                  raise OSError
              except OSError:
                  raise ValueError
  
          def test_functional(self):
              self.assertRaises(ValueError, self.foo)
  
          def test_with(self):
              with self.assertRaises(ValueError):
                  self.foo()
  
      Foo("test_functional").run()
      gc_collect()  # For PyPy or other GCs.
      self.assertIsNone(wr())
      Foo("test_with").run()
      gc_collect()  # For PyPy or other GCs.
      self.assertIsNone(wr())
  
imports: import datetime
  import warnings
  import weakref
  import unittest
  from test.support import gc_collect
  from itertools import product
label_desc: Use image node_id 4 for calling the Test_Assertions obj's underlying member method code with example usage: obj.test_assertRaises_frames_survival() without return types