[pypy-svn] r68828 - pypy/trunk/pypy/interpreter/test
cfbolz at codespeak.net
cfbolz at codespeak.net
Wed Oct 28 18:19:54 CET 2009
Author: cfbolz
Date: Wed Oct 28 18:19:54 2009
New Revision: 68828
Modified:
pypy/trunk/pypy/interpreter/test/test_function.py
Log:
a test about writing the func_code attribute of functions
Modified: pypy/trunk/pypy/interpreter/test/test_function.py
==============================================================================
--- pypy/trunk/pypy/interpreter/test/test_function.py (original)
+++ pypy/trunk/pypy/interpreter/test/test_function.py Wed Oct 28 18:19:54 2009
@@ -70,6 +70,22 @@
f = g(42)
raises(TypeError, FuncType, f.func_code, f.func_globals, 'f2', None, None)
+ def test_write_code(self):
+ def f():
+ return 42
+ def g():
+ return 41
+ assert f() == 42
+ assert g() == 41
+ raises(TypeError, "f.func_code = 1")
+ f.func_code = g.func_code
+ assert f() == 41
+ def h():
+ return f() # a closure
+ raises(ValueError, "f.func_code = h.func_code")
+
+
+
class AppTestFunction:
def test_simple_call(self):
def func(arg1, arg2):
More information about the Pypy-commit
mailing list