diff options
author | Guido van Rossum <guido@python.org> | 1995-01-02 18:38:42 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1995-01-02 18:38:42 (GMT) |
commit | 824de25fe2edade0ded378b4d602351272f4cf63 (patch) | |
tree | bad870acf30a9180e9edb573f00ff90d2e26a20f /Lib | |
parent | 40b2cfb3f39e3db4c5f04f0545f9af7d299c2f4f (diff) | |
download | cpython-824de25fe2edade0ded378b4d602351272f4cf63.zip cpython-824de25fe2edade0ded378b4d602351272f4cf63.tar.gz cpython-824de25fe2edade0ded378b4d602351272f4cf63.tar.bz2 |
* Lib/test/test_b1.py: test eval() and execfile() with globals,
locals arguments
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_b1.py | 13 |
1 files changed, 13 insertions, 0 deletions
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' |