code: def test_raises_on(self) -> None:
      with self.assertRaisesOn(RuntimeError, "raise e"):
          _f()
  
      # Check that we fail if the source line is not what we expect
      with self.assertRaisesRegex(
          Exception, "was not found in the traceback"
      ):
          with self.assertRaisesOn(
              RuntimeError, 'raise Exception("Test")'
          ):
              _f()
  
      # Check that the exception passes through if it's not the one we meant to catch
      with self.assertRaisesRegex(RuntimeError, "Test"):
          with self.assertRaisesOn(AssertionError, "raise e"):
              _f()
  
      with self.assertRaisesOn(
          RuntimeError, "_f()  # Lines along the path are matched too"
      ):
          _g()
  
      # Use this as a context manager to get the position of an error
      with self.assertRaisesOn(RuntimeError) as cm:
          _f()
      # pyre-fixme[16]: `None` has no attribute `filename`.
      self.assertEqual(cm.filename, __file__)
      # pyre-fixme[16]: `None` has no attribute `lineno`.
      self.assertEqual(cm.lineno, F_FAILURE_LINENO)
  
file_path: Ax/ax/utils/common/tests/test_testutils.py
imports: import io
  import sys
  from ax.utils.common.base import Base
  from ax.utils.common.testutils import TestCase
label_desc: Use image node_id 2 for calling the TestTestUtils obj's underlying member method code with example usage: obj.test_raises_on() without return types