def METHOD_NAME(self):
    endly = False
    def g():
        nonlocal endly
        try:
            yield
            inner()
        finally:
            endly = True
    gen = g()
    next(gen)
    self.assertFalse(endly)
    # Clearing the frame closes the generator
    gen.gi_frame.clear()
    self.assertTrue(endly)