utils.javascript: Handle bools in _convert_js_arg

This commit is contained in:
Florian Bruhin 2016-08-18 12:29:05 +02:00
parent b596c4da27
commit 30029a8259
2 changed files with 4 additions and 0 deletions

View File

@ -52,6 +52,8 @@ def _convert_js_arg(arg):
return 'undefined'
elif isinstance(arg, str):
return '"{}"'.format(string_escape(arg))
elif isinstance(arg, bool):
return str(arg).lower()
elif isinstance(arg, (int, float)):
return str(arg)
else:

View File

@ -127,8 +127,10 @@ class TestStringEscape:
('foo\\bar', r'"foo\\bar"'),
(42, '42'),
(23.42, '23.42'),
(False, 'false'),
(None, 'undefined'),
(object(), TypeError),
(True, 'true'),
])
def test_convert_js_arg(arg, expected):
if expected is TypeError: