[test_utils] Add tests for malformed JSON handling in js_to_json
authorSergey M․ <dstftw@gmail.com>
Sat, 20 Jan 2018 15:58:48 +0000 (22:58 +0700)
committerSergey M․ <dstftw@gmail.com>
Sat, 20 Jan 2018 16:00:09 +0000 (23:00 +0700)
test/test_utils.py

index 6ef498a66608151a35e4da1ef9f58ad2cd42b5b6..fdf6031f7db157b4989aafc345380ce184f91458 100644 (file)
@@ -891,6 +891,10 @@ class TestUtil(unittest.TestCase):
         on = js_to_json('{42:4.2e1}')
         self.assertEqual(json.loads(on), {'42': 42.0})
 
+    def test_js_to_json_malformed(self):
+        self.assertEqual(js_to_json('42a1'), '42"a1"')
+        self.assertEqual(js_to_json('42a-1'), '42"a"-1')
+
     def test_extract_attributes(self):
         self.assertEqual(extract_attributes('<e x="y">'), {'x': 'y'})
         self.assertEqual(extract_attributes("<e x='y'>"), {'x': 'y'})