From 824de25fe2edade0ded378b4d602351272f4cf63 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 2 Jan 1995 18:38:42 +0000 Subject: * Lib/test/test_b1.py: test eval() and execfile() with globals, locals arguments --- Lib/test/test_b1.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Lib/test/test_b1.py b/Lib/test/test_b1.py index 356edd2..f0a6bd6 100644 --- a/Lib/test/test_b1.py +++ b/Lib/test/test_b1.py @@ -111,6 +111,12 @@ if fcmp(divmod(-3.25, -1.0), (3.0, -0.25)): print 'eval' if eval('1+1') <> 2: raise TestFailed, 'eval(\'1+1\')' if eval(' 1+1\n') <> 2: raise TestFailed, 'eval(\' 1+1\\n\')' +globals = {'a': 1, 'b': 2} +locals = {'b': 200, 'c': 300} +if eval('a', globals) <> 1: raise TestFailed, "eval(1)" +if eval('a', globals, locals) <> 1: raise TestFailed, "eval(2)" +if eval('b', globals, locals) <> 200: raise TestFailed, "eval(3)" +if eval('c', globals, locals) <> 300: raise TestFailed, "eval(4)" print 'execfile' z = 0 @@ -119,6 +125,13 @@ f.write('z = z+1\n') f.write('z = z*2\n') f.close() execfile(TESTFN) +if z <> 2: raise TestFailed, "execfile(1)" +globals['z'] = 0 +execfile(TESTFN, globals) +if globals['z'] <> 2: raise TestFailed, "execfile(1)" +locals['z'] = 0 +execfile(TESTFN, globals, locals) +if locals['z'] <> 2: raise TestFailed, "execfile(1)" unlink(TESTFN) print 'filter' -- cgit v0.12