class_docstr: Test semantics.
class_docstr_tok: ["Test","semantics","."]
docstr: Test handling exception while delegating 'send'
docstr_tok: ["Test","handling","exception","while","delegating","'send","'"]
code: def test_handling_exception_while_delegating_send(self):
      """
      Test handling exception while delegating 'send'
      """
      trace = []
  
      def g1():
          trace.append("Starting g1")
          x = yield "g1 ham"
          trace.append("g1 received %s" % (x,))
          yield from g2()
          x = yield "g1 eggs"
          trace.append("g1 received %s" % (x,))
          trace.append("Finishing g1")
  
      def g2():
          trace.append("Starting g2")
          x = yield "g2 spam"
          trace.append("g2 received %s" % (x,))
          raise ValueError("hovercraft is full of eels")
          x = yield "g2 more spam"
          trace.append("g2 received %s" % (x,))
          trace.append("Finishing g2")
  
      def run():
          g = g1()
          y = next(g)
          x = 1
          try:
              while 1:
                  y = g.send(x)
                  trace.append("Yielded %s" % (y,))
                  x += 1
          except StopIteration:
              trace.append("StopIteration")
  
      self.assertRaises(ValueError, run)
      self.assertEqual(
          trace,
          [
              "Starting g1",
              "g1 received 1",
              "Starting g2",
              "Yielded g2 spam",
              "g2 received 2",
          ],
      )
  
imports: import unittest
  import inspect
  from test.support import captured_stderr, disable_gc, gc_collect
  from test import support
label_desc: Use image node_id 6 for calling the TestPEP380Operation obj's underlying member method code with example usage: obj.test_handling_exception_while_delegating_send() without return types