comparison test_pymonkey.py @ 59:fb97bed55789

Added a test that fails b/c of a known bug in pymonkey.
author Atul Varma <varmaa@toolness.com>
date Sun, 19 Jul 2009 20:27:25 -0700
parents a2b617731398
children 1506350991d4
comparison
equal deleted inserted replaced
58:7a3461ccaf1d 59:fb97bed55789
1 import sys 1 import sys
2 import unittest 2 import unittest
3 import weakref
3 4
4 import pymonkey 5 import pymonkey
5 6
6 class PymonkeyTests(unittest.TestCase): 7 class PymonkeyTests(unittest.TestCase):
7 def _evaljs(self, code): 8 def _evaljs(self, code):
30 31
31 def testUndefinedStrIsUndefined(self): 32 def testUndefinedStrIsUndefined(self):
32 self.assertEqual(str(pymonkey.undefined), 33 self.assertEqual(str(pymonkey.undefined),
33 "pymonkey.undefined") 34 "pymonkey.undefined")
34 35
36 def testJsWrappedPythonFuncIsNotGCd(self):
37 # TODO: Make this test pass.
38 def define(cx, obj):
39 def func(cx, this, args):
40 return u'func was called'
41 jsfunc = cx.new_function(func, func.__name__)
42 cx.define_property(obj, func.__name__, jsfunc)
43 return weakref.ref(func)
44 cx = pymonkey.Runtime().new_context()
45 obj = cx.new_object()
46 cx.init_standard_classes(obj)
47 ref = define(cx, obj)
48 self.assertNotEqual(ref(), None)
49 result = cx.evaluate_script(obj, 'func()', '<string>', 1)
50 self.assertEqual(result, u'func was called')
51
35 def testJsWrappedPythonFuncPassesContext(self): 52 def testJsWrappedPythonFuncPassesContext(self):
36 contexts = [] 53 contexts = []
37 54
38 def func(cx, this, args): 55 def func(cx, this, args):
39 contexts.append(cx) 56 contexts.append(cx)