Mercurial > pymonkey
diff test_pymonkey.py @ 47:3f4982759e55
Converting JS exceptions into Python exceptions is now doable, albeit not yet implemented, thanks to the discovery of JSOPTION_DONT_REPORT_UNCAUGHT. Also, JS warnings are now converted into Python warnings.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 06 Jul 2009 08:13:45 -0700 |
parents | a0f677cfc679 |
children | 427b01954b22 |
line wrap: on
line diff
--- a/test_pymonkey.py Mon Jul 06 01:37:16 2009 -0700 +++ b/test_pymonkey.py Mon Jul 06 08:13:45 2009 -0700 @@ -57,7 +57,7 @@ self._evalJsWrappedPyFunc, hai2u, 'hai2u()') self.assertEqual(self.last_exception.message, - "uncaught exception: hello") + "hello") def testJsWrappedPythonFunctionReturnsNone(self): def hai2u(cx): @@ -127,7 +127,7 @@ cx = pymonkey.Runtime().new_context() obj = cx.new_object() cx.init_standard_classes(obj) - cx.evaluate_script(obj, 'foo = {bar: 1}', '<string>', 1) + cx.evaluate_script(obj, 'var foo = {bar: 1}', '<string>', 1) self.assertTrue(isinstance(cx.get_property(obj, u"foo"), pymonkey.Object)) self.assertTrue(cx.get_property(obj, u"foo") is @@ -137,7 +137,7 @@ cx = pymonkey.Runtime().new_context() obj = cx.new_object() cx.init_standard_classes(obj) - cx.evaluate_script(obj, 'boop = 5', '<string>', 1) + cx.evaluate_script(obj, 'var boop = 5', '<string>', 1) cx.evaluate_script(obj, 'this["blarg\u2026"] = 5', '<string>', 1) self.assertEqual(cx.get_property(obj, u"beans"), pymonkey.undefined) @@ -181,8 +181,7 @@ self.assertRaises(pymonkey.error, self._evaljs, 'hai2u()') self.assertEqual(self.last_exception.message, - 'File "<string>", line 1: ReferenceError: ' - 'hai2u is not defined') + 'ReferenceError: hai2u is not defined') def testEvaluateReturnsUndefined(self): retval = self._evaljs("") @@ -243,8 +242,7 @@ cx.call_function, obj, obj, (1,)) self.assertEqual(self.last_exception.message, - 'File "<string>", line 1: ReferenceError: ' - 'blarg is not defined') + 'ReferenceError: blarg is not defined') def testCallFunctionWorks(self): cx = pymonkey.Runtime().new_context()