def test_console_closure_variables(monkeypatch): # restore the original display hook monkeypatch.setattr(sys, "displayhook", console._displayhook) c = console.Console() c.eval("y = 5") c.eval("x = lambda: y") ret = c.eval("x()") assert ret == ">>> x()\n5\n"
def test_console_closure_variables(monkeypatch): # restore the original display hook monkeypatch.setattr(sys, "displayhook", console._displayhook) c = console.Console() c.eval("y = 5") c.eval("x = lambda: y") # strip() is only needed for Python 2 compat ret = c.eval("x()").strip() assert ret == ">>> x()\n5"