Allow lists for javascript.convert_js_arg
This commit is contained in:
parent
b8ab378083
commit
1647c28632
@ -59,6 +59,8 @@ def _convert_js_arg(arg):
|
|||||||
return str(arg).lower()
|
return str(arg).lower()
|
||||||
elif isinstance(arg, (int, float)):
|
elif isinstance(arg, (int, float)):
|
||||||
return str(arg)
|
return str(arg)
|
||||||
|
elif isinstance(arg, list):
|
||||||
|
return '[{}]'.format(', '.join(_convert_js_arg(e) for e in arg))
|
||||||
else:
|
else:
|
||||||
raise TypeError("Don't know how to handle {!r} of type {}!".format(
|
raise TypeError("Don't know how to handle {!r} of type {}!".format(
|
||||||
arg, type(arg).__name__))
|
arg, type(arg).__name__))
|
||||||
|
@ -84,6 +84,7 @@ class TestStringEscape:
|
|||||||
(None, 'undefined'),
|
(None, 'undefined'),
|
||||||
(object(), TypeError),
|
(object(), TypeError),
|
||||||
(True, 'true'),
|
(True, 'true'),
|
||||||
|
([23, True, 'x'], '[23, true, "x"]'),
|
||||||
])
|
])
|
||||||
def test_convert_js_arg(arg, expected):
|
def test_convert_js_arg(arg, expected):
|
||||||
if expected is TypeError:
|
if expected is TypeError:
|
||||||
|
Loading…
Reference in New Issue
Block a user