Browse Source

[test_utils] Add tests for malformed JSON handling in js_to_json

master-ytdl-org
Sergey M․ 7 years ago
parent
commit
c707b1d828
No known key found for this signature in database GPG Key ID: 2C393E0F18A9236D
1 changed files with 4 additions and 0 deletions
  1. +4
    -0
      test/test_utils.py

+ 4
- 0
test/test_utils.py View 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'})


Loading…
Cancel
Save