aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMike Fährmann <mike_faehrmann@web.de>2018-01-20 16:54:21 +0100
committerSergey M <dstftw@gmail.com>2018-01-20 22:54:21 +0700
commitc384d537f882efab10a78a56ce6dcb0a30f54b47 (patch)
tree9e08a36b8eb3352c748c8911971a13aff24d26ef /test
parente7f3529f68ee7c8ca78366d37f851cb31fa00f31 (diff)
[util] Improve scientific notation handling in js_to_json (closes #14789)
Diffstat (limited to 'test')
-rw-r--r--test/test_utils.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/test_utils.py b/test/test_utils.py
index 0857c0fc0..6ef498a66 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -814,6 +814,9 @@ class TestUtil(unittest.TestCase):
inp = '''{"duration": "00:01:07"}'''
self.assertEqual(js_to_json(inp), '''{"duration": "00:01:07"}''')
+ inp = '''{segments: [{"offset":-3.885780586188048e-16,"duration":39.75000000000001}]}'''
+ self.assertEqual(js_to_json(inp), '''{"segments": [{"offset":-3.885780586188048e-16,"duration":39.75000000000001}]}''')
+
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"})
@@ -885,6 +888,9 @@ class TestUtil(unittest.TestCase):
on = js_to_json('{/*comment\n*/42/*comment\n*/:/*comment\n*/42/*comment\n*/}')
self.assertEqual(json.loads(on), {'42': 42})
+ on = js_to_json('{42:4.2e1}')
+ self.assertEqual(json.loads(on), {'42': 42.0})
+
def test_extract_attributes(self):
self.assertEqual(extract_attributes('<e x="y">'), {'x': 'y'})
self.assertEqual(extract_attributes("<e x='y'>"), {'x': 'y'})