MCPcopy Index your code
hub / github.com/python/cpython / test_delegating_close

Method test_delegating_close

Lib/test/test_yield_from.py:226–258  ·  view source on GitHub ↗

Test delegating 'close'

(self)

Source from the content-addressed store, hash-verified

224 ])
225
226 def test_delegating_close(self):
227 """
228 Test delegating 'close'
229 """
230 trace = []
231 def g1():
232 try:
233 trace.append("Starting g1")
234 yield "g1 ham"
235 yield from g2()
236 yield "g1 eggs"
237 finally:
238 trace.append("Finishing g1")
239 def g2():
240 try:
241 trace.append("Starting g2")
242 yield "g2 spam"
243 yield "g2 more spam"
244 finally:
245 trace.append("Finishing g2")
246 g = g1()
247 for i in range(2):
248 x = next(g)
249 trace.append("Yielded %s" % (x,))
250 g.close()
251 self.assertEqual(trace,[
252 "Starting g1",
253 "Yielded g1 ham",
254 "Starting g2",
255 "Yielded g2 spam",
256 "Finishing g2",
257 "Finishing g1"
258 ])
259
260 def test_handing_exception_while_delegating_close(self):
261 """

Callers

nothing calls this directly

Calls 4

g1Function · 0.85
appendMethod · 0.45
closeMethod · 0.45
assertEqualMethod · 0.45

Tested by

no test coverage detected