# HG changeset patch # User Atul Varma # Date 1248060445 25200 # Node ID fb97bed55789c100a7be06aea8d61d38de52e9a3 # Parent 7a3461ccaf1d96493b890143ae47be1e40c05619 Added a test that fails b/c of a known bug in pymonkey. diff -r 7a3461ccaf1d -r fb97bed55789 test_pymonkey.py --- a/test_pymonkey.py Sun Jul 19 19:58:15 2009 -0700 +++ b/test_pymonkey.py Sun Jul 19 20:27:25 2009 -0700 @@ -1,5 +1,6 @@ import sys import unittest +import weakref import pymonkey @@ -32,6 +33,22 @@ self.assertEqual(str(pymonkey.undefined), "pymonkey.undefined") + def testJsWrappedPythonFuncIsNotGCd(self): + # TODO: Make this test pass. + def define(cx, obj): + def func(cx, this, args): + return u'func was called' + jsfunc = cx.new_function(func, func.__name__) + cx.define_property(obj, func.__name__, jsfunc) + return weakref.ref(func) + cx = pymonkey.Runtime().new_context() + obj = cx.new_object() + cx.init_standard_classes(obj) + ref = define(cx, obj) + self.assertNotEqual(ref(), None) + result = cx.evaluate_script(obj, 'func()', '', 1) + self.assertEqual(result, u'func was called') + def testJsWrappedPythonFuncPassesContext(self): contexts = []