[pypy-svn] rev 838 - in pypy/trunk/src/pypy: appspace/test interpreter
rocco at codespeak.net
rocco at codespeak.net
Fri Jun 20 03:14:11 CEST 2003
Author: rocco
Date: Fri Jun 20 03:14:10 2003
New Revision: 838
Modified:
pypy/trunk/src/pypy/appspace/test/test_exec.py
pypy/trunk/src/pypy/interpreter/opcode.py
pypy/trunk/src/pypy/interpreter/opcode_app.py
Log:
Change test_exec to new style of app level tests, update EXEC_STMT for new calling style.
Modified: pypy/trunk/src/pypy/appspace/test/test_exec.py
==============================================================================
--- pypy/trunk/src/pypy/appspace/test/test_exec.py (original)
+++ pypy/trunk/src/pypy/appspace/test/test_exec.py Fri Jun 20 03:14:10 2003
@@ -3,11 +3,12 @@
New for PyPy - Could be incorporated into CPython regression tests.
"""
import autopath
-
-import unittest
from pypy.tool import test
-class TestExecStmt(test.TestCase):
+class TestExecStmt(test.AppTestCase):
+
+ def setUp(self):
+ self.space = test.objspace()
def test_string(self):
g = {}
@@ -26,10 +27,14 @@
self.failUnless(g.has_key('__builtins__'))
def test_invalidglobal(self):
- self.failUnlessRaises(TypeError,"exec 'pass' in 1")
+ def f():
+ exec 'pass' in 1
+ self.failUnlessRaises(TypeError,f)
def test_invalidlocal(self):
- self.failUnlessRaises(TypeError,"exec 'pass' in {}, 2")
+ def f():
+ exec 'pass' in {}, 2
+ self.failUnlessRaises(TypeError,f)
def test_codeobject(self):
co = compile("a = 3", '<string>', 'exec')
@@ -63,7 +68,9 @@
self.failUnlessEqual(g['a'], 3)
def test_exceptionfallthrough(self):
- self.failUnlessRaises(TypeError,"exec 'raise TypeError' in {}")
+ def f():
+ exec 'raise TypeError' in {}
+ self.failUnlessRaises(TypeError,f)
if __name__ == "__main__":
- unittest.main()
+ test.main()
Modified: pypy/trunk/src/pypy/interpreter/opcode.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/opcode.py (original)
+++ pypy/trunk/src/pypy/interpreter/opcode.py Fri Jun 20 03:14:10 2003
@@ -290,9 +290,8 @@
w_prog = f.space.getitem(w_tuple,f.space.wrap(0))
w_globals = f.space.getitem(w_tuple,f.space.wrap(1))
w_locals = f.space.getitem(w_tuple,f.space.wrap(2))
- newframe = pyframe.PyFrame(f.space,f.space.unwrap(w_prog),w_globals,w_locals)
- ec = f.space.getexecutioncontext()
- ec.eval_frame(newframe) #discard return value
+
+ w_prog.eval_code(f.space, w_globals, w_locals)
def POP_BLOCK(f):
block = f.blockstack.pop()
Modified: pypy/trunk/src/pypy/interpreter/opcode_app.py
==============================================================================
--- pypy/trunk/src/pypy/interpreter/opcode_app.py (original)
+++ pypy/trunk/src/pypy/interpreter/opcode_app.py Fri Jun 20 03:14:10 2003
@@ -151,7 +151,7 @@
"""
import types
if (globals is None and locals is None and
- isinstance(prog, builtins.tuple) and
+ isinstance(prog, builtins['tuple']) and
(len(prog) == 2 or len(prog) == 3)):
globals = prog[1]
if len(prog) == 3:
@@ -169,7 +169,7 @@
globals['__builtins__'] = builtins
if not isinstance(locals, types.DictType):
raise TypeError("exec: arg 3 must be a dictionary or None")
- #HACK to check for code object
+ # XXX - HACK to check for code object
co = compile('1','<string>','eval')
if isinstance(prog, type(co)):
return (prog, globals, locals)
More information about the Pypy-commit
mailing list