comparison test_pymonkey.py @ 86:16a3e99e9b77

JS-wrapped Python functions that have had their Python functions cleared by context.clear_object_private() now throw appropriate JS exceptions when called.
author Atul Varma <varmaa@toolness.com>
date Sun, 09 Aug 2009 15:46:40 -0700
parents 10205d88f6ff
children 345d4c0e3dd3
comparison
equal deleted inserted replaced
85:e9f450d30c0e 86:16a3e99e9b77
151 del rt 151 del rt
152 del cx 152 del cx
153 del obj 153 del obj
154 self.assertEqual(ref(), None) 154 self.assertEqual(ref(), None)
155 155
156 def testJsWrappedPythonFuncThrowsExcIfPrivateCleared(self):
157 def func(cx, this, args):
158 return True
159
160 code = "func()"
161 cx = pymonkey.Runtime().new_context()
162 obj = cx.new_object()
163 cx.init_standard_classes(obj)
164 jsfunc = cx.new_function(func, func.__name__)
165 cx.define_property(obj, func.__name__, jsfunc)
166 cx.clear_object_private(jsfunc)
167 self.assertRaises(pymonkey.error,
168 cx.evaluate_script,
169 obj, code, '<string>', 1)
170 self.assertEqual(
171 self._tostring(cx, self.last_exception.message),
172 "Error: Wrapped Python function no longer exists"
173 )
174
156 def testJsWrappedPythonFuncPassesContext(self): 175 def testJsWrappedPythonFuncPassesContext(self):
157 contexts = [] 176 contexts = []
158 177
159 def func(cx, this, args): 178 def func(cx, this, args):
160 contexts.append(cx) 179 contexts.append(cx)