Allow lists for javascript.convert_js_arg

This commit is contained in:
Florian Bruhin 2018-09-08 16:20:38 +02:00
parent b8ab378083
commit 1647c28632
2 changed files with 3 additions and 0 deletions

View File

@ -59,6 +59,8 @@ def _convert_js_arg(arg):
return str(arg).lower()
elif isinstance(arg, (int, float)):
return str(arg)
elif isinstance(arg, list):
return '[{}]'.format(', '.join(_convert_js_arg(e) for e in arg))
else:
raise TypeError("Don't know how to handle {!r} of type {}!".format(
arg, type(arg).__name__))

View File

@ -84,6 +84,7 @@ class TestStringEscape:
(None, 'undefined'),
(object(), TypeError),
(True, 'true'),
([23, True, 'x'], '[23, true, "x"]'),
])
def test_convert_js_arg(arg, expected):
if expected is TypeError: