Add quotes for strings in javascript.assemble
This commit is contained in:
parent
08b70f0f4c
commit
a8ef956726
@ -54,7 +54,7 @@ def _convert_js_arg(arg):
|
|||||||
if arg is None:
|
if arg is None:
|
||||||
return 'undefined'
|
return 'undefined'
|
||||||
elif isinstance(arg, str):
|
elif isinstance(arg, str):
|
||||||
return string_escape(arg)
|
return '"{}"'.format(string_escape(arg))
|
||||||
elif isinstance(arg, int):
|
elif isinstance(arg, int):
|
||||||
return str(arg)
|
return str(arg)
|
||||||
else:
|
else:
|
||||||
|
@ -123,8 +123,8 @@ class TestStringEscape:
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.parametrize('arg, expected', [
|
@pytest.mark.parametrize('arg, expected', [
|
||||||
('foobar', 'foobar'),
|
('foobar', '"foobar"'),
|
||||||
('foo\\bar', r'foo\\bar'),
|
('foo\\bar', r'"foo\\bar"'),
|
||||||
(42, '42'),
|
(42, '42'),
|
||||||
(None, 'undefined'),
|
(None, 'undefined'),
|
||||||
(object(), TypeError),
|
(object(), TypeError),
|
||||||
|
Loading…
Reference in New Issue
Block a user