def test_as_decorator(): ns = {} exec('\n'.join(['def func():'] + ['\t' + x for x in CODE.splitlines() + ['return result']]), ns) assert with_goto(ns['func'])() == EXPECTED
def test_with_code(): ns = {} exec(with_goto(compile(CODE, '', 'exec')), ns) assert ns['result'] == EXPECTED