From 8b1863dec98d8d435934c9d2cd5b8a63d4cd189d Mon Sep 17 00:00:00 2001 From: hbw Date: Thu, 27 May 2021 10:39:23 -0700 Subject: [PATCH] add unit test for function parse_m3u3_attributes in utils.py --- test/test_utils.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/test_utils.py b/test/test_utils.py index 259c4763e..ff2095878 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -91,6 +91,7 @@ from youtube_dl.utils import ( urljoin, urlencode_postdata, urshift, + parse_m3u8_attributes, update_url_query, version_tuple, xpath_with_ns, @@ -1427,6 +1428,17 @@ Line 1 self.assertEqual(rot47('youtube-dl'), r'J@FEF36\5=') self.assertEqual(rot47('YOUTUBE-DL'), r'*~&%&qt\s{') + def test_parse_m3u7_attributes(self): + self.assertEqual(parse_m3u8_attributes("1=2"), {'1': '2'}) + self.assertEqual(parse_m3u8_attributes("A=B"), {'A': 'B'}) + self.assertEqual(parse_m3u8_attributes("1A=2"), {'1A': '2'}) + self.assertEqual(parse_m3u8_attributes("1=2B"), {'1': '2B'}) + self.assertEqual(parse_m3u8_attributes("1=2,3=4"), {'1':'2', '3':'4'}) + self.assertEqual(parse_m3u8_attributes("1=\"2\""), {'1':'2'}) + self.assertEqual(parse_m3u8_attributes("1a=2"), {}) + self.assertEqual(parse_m3u8_attributes("1=2b"), {'1':'2b'}) + self.assertEqual(parse_m3u8_attributes(""), {}) + def test_urshift(self): self.assertEqual(urshift(3, 1), 1) self.assertEqual(urshift(-3, 1), 2147483646)