def METHOD_NAME(self):
    def foo():
        x = range(3)
        yield len(x)
        yield len(x)
    self.configure_func(foo)
    g = foo()
    self.assertEqual(next(g), 3)
    with swap_item(globals(), "__builtins__", {"len": lambda x: 7}):
        self.assertEqual(next(g), 3)