aboutsummaryrefslogtreecommitdiff
path: root/test/test_utils.py
diff options
context:
space:
mode:
authorSergey M․ <dstftw@gmail.com>2016-05-14 20:39:58 +0600
committerSergey M․ <dstftw@gmail.com>2016-05-14 20:39:58 +0600
commit89ac4a19e658203db85c6a1d4b267a2eeb47a38e (patch)
treed076cf3a60b4960e63d0b5803a8d2151509b5498 /test/test_utils.py
parent640eea0a0cf7ae589126f7762e1cfc7bdd2250d9 (diff)
[utils] Process non-base 10 integers in js_to_json
Diffstat (limited to 'test/test_utils.py')
-rw-r--r--test/test_utils.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index ab2842f3b..26f66bff6 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -617,6 +617,15 @@ class TestUtil(unittest.TestCase):
json_code = js_to_json(inp)
self.assertEqual(json.loads(json_code), json.loads(inp))
+ inp = '''{
+ 0:{src:'skipped', type: 'application/dash+xml'},
+ 1:{src:'skipped', type: 'application/vnd.apple.mpegURL'},
+ }'''
+ self.assertEqual(js_to_json(inp), '''{
+ "0":{"src":"skipped", "type": "application/dash+xml"},
+ "1":{"src":"skipped", "type": "application/vnd.apple.mpegURL"}
+ }''')
+
def test_js_to_json_edgecases(self):
on = js_to_json("{abc_def:'1\\'\\\\2\\\\\\'3\"4'}")
self.assertEqual(json.loads(on), {"abc_def": "1'\\2\\'3\"4"})
@@ -652,6 +661,16 @@ class TestUtil(unittest.TestCase):
on = js_to_json("['a\\\nb']")
self.assertEqual(json.loads(on), ['ab'])
+ on = js_to_json('{0xff:0xff}')
+ self.assertEqual(json.loads(on), {'255': 255})
+
+ on = js_to_json('{077:077}')
+ self.assertEqual(json.loads(on), {'63': 63})
+
+ on = js_to_json('{42:42}')
+ self.assertEqual(json.loads(on), {'42': 42})
+
+
def test_extract_attributes(self):
self.assertEqual(extract_attributes('<e x="y">'), {'x': 'y'})
self.assertEqual(extract_attributes("<e x='y'>"), {'x': 'y'})