def test_py2js_funcformatter_arg_and_kwarg(self): def test(x, pos=None): return '%s$' % x jsfunc = util.py2js_tickformatter(test) js_func = ('var x = tick;\nvar formatter;\nformatter = function () {\n' ' pos = (pos === undefined) ? null: pos;\n return "" ' '+ x + "$";\n};\n\nreturn formatter();\n') self.assertEqual(jsfunc, js_func)
def test_py2js_funcformatter_two_args(self): def test(x, pos): return '%s$' % x jsfunc = util.py2js_tickformatter(test) js_func = ('var x = tick;\nvar formatter;\nformatter = function () {\n' ' return "" + x + "$";\n};\n\nreturn formatter();\n') self.assertEqual(jsfunc, js_func)