aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorfelix <felix.von.s@posteo.de>2016-03-13 12:29:15 +0100
committerSergey M․ <dstftw@gmail.com>2016-05-14 20:12:39 +0600
commitbd1e484448c84904ce0d99fe05c3721053aa3c00 (patch)
tree868cf78d55d90e46fad38e87575ba0d348d53fae /test
parenta834622b89031dad5afbf96e4a5939a66b0d054b (diff)
[utils] js_to_json: various improvements
now JS object literals like { /* " */ 0: ",]\xaa<\/p>", } will be correctly converted to JSON.
Diffstat (limited to 'test')
-rw-r--r--test/test_utils.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index ca254779f..ab2842f3b 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -640,6 +640,18 @@ class TestUtil(unittest.TestCase):
on = js_to_json('{"abc": "def",}')
self.assertEqual(json.loads(on), {'abc': 'def'})
+ on = js_to_json('{ 0: /* " \n */ ",]" , }')
+ self.assertEqual(json.loads(on), {'0': ',]'})
+
+ on = js_to_json(r'["<p>x<\/p>"]')
+ self.assertEqual(json.loads(on), ['<p>x</p>'])
+
+ on = js_to_json(r'["\xaa"]')
+ self.assertEqual(json.loads(on), ['\u00aa'])
+
+ on = js_to_json("['a\\\nb']")
+ self.assertEqual(json.loads(on), ['ab'])
+
def test_extract_attributes(self):
self.assertEqual(extract_attributes('<e x="y">'), {'x': 'y'})
self.assertEqual(extract_attributes("<e x='y'>"), {'x': 'y'})