def test_getglobals(self, space): assert PyEval_GetLocals(space) is None assert PyEval_GetGlobals(space) is None def cpyvars(space): return space.newtuple([PyEval_GetGlobals(space), PyEval_GetLocals(space)]) w_cpyvars = space.wrap(interp2app(cpyvars)) w_result = space.appexec([w_cpyvars], """(cpyvars): x = 1 return cpyvars() \ny = 2 """) globals, locals = space.unwrap(w_result) assert sorted(locals) == ['cpyvars', 'x'] assert sorted(globals) == ['__builtins__', 'anonymous', 'y']
def cpyvars(space): return space.newtuple( [PyEval_GetGlobals(space), PyEval_GetLocals(space)])