class_docstr: Test semantics.
class_docstr_tok: ["Test","semantics","."]
docstr: Test attempted yield-from loop
docstr_tok: ["Test","attempted","yield-from","loop"]
code: def test_attempted_yield_from_loop(self):
      """
      Test attempted yield-from loop
      """
      trace = []
  
      def g1():
          trace.append("g1: starting")
          yield "y1"
          trace.append("g1: about to yield from g2")
          yield from g2()
          trace.append("g1 should not be here")
  
      def g2():
          trace.append("g2: starting")
          yield "y2"
          trace.append("g2: about to yield from g1")
          yield from gi
          trace.append("g2 should not be here")
  
      try:
          gi = g1()
          for y in gi:
              trace.append("Yielded: %s" % (y,))
      except ValueError as e:
          self.assertEqual(e.args[0], "generator already executing")
      else:
          self.fail("subgenerator didn't raise ValueError")
      self.assertEqual(
          trace,
          [
              "g1: starting",
              "Yielded: y1",
              "g1: about to yield from g2",
              "g2: starting",
              "Yielded: y2",
              "g2: about to yield from g1",
          ],
      )
  
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 20 for calling the TestPEP380Operation obj's underlying member method code with example usage: obj.test_attempted_yield_from_loop() without return types