diff options
Diffstat (limited to 'test/test_compat.py')
-rw-r--r-- | test/test_compat.py | 29 |
1 files changed, 8 insertions, 21 deletions
diff --git a/test/test_compat.py b/test/test_compat.py index ce95a6afa..62bf5a306 100644 --- a/test/test_compat.py +++ b/test/test_compat.py @@ -7,16 +7,15 @@ import unittest sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +import struct +import urllib.parse + from yt_dlp import compat from yt_dlp.compat import ( compat_etree_fromstring, compat_expanduser, - compat_getenv, - compat_setenv, compat_str, - compat_struct_unpack, compat_urllib_parse_unquote, - compat_urllib_parse_unquote_plus, compat_urllib_parse_urlencode, ) @@ -31,26 +30,14 @@ class TestCompat(unittest.TestCase): compat.asyncio.events # Must not raise error - def test_compat_getenv(self): - test_str = 'тест' - compat_setenv('yt_dlp_COMPAT_GETENV', test_str) - self.assertEqual(compat_getenv('yt_dlp_COMPAT_GETENV'), test_str) - - def test_compat_setenv(self): - test_var = 'yt_dlp_COMPAT_SETENV' - test_str = 'тест' - compat_setenv(test_var, test_str) - compat_getenv(test_var) - self.assertEqual(compat_getenv(test_var), test_str) - def test_compat_expanduser(self): old_home = os.environ.get('HOME') test_str = R'C:\Documents and Settings\тест\Application Data' try: - compat_setenv('HOME', test_str) + os.environ['HOME'] = test_str self.assertEqual(compat_expanduser('~'), test_str) finally: - compat_setenv('HOME', old_home or '') + os.environ['HOME'] = old_home or '' def test_compat_urllib_parse_unquote(self): self.assertEqual(compat_urllib_parse_unquote('abc%20def'), 'abc def') @@ -72,8 +59,8 @@ class TestCompat(unittest.TestCase): '''(^◣_◢^)っ︻デ═一 ⇀ ⇀ ⇀ ⇀ ⇀ ↶%I%Break%Things%''') def test_compat_urllib_parse_unquote_plus(self): - self.assertEqual(compat_urllib_parse_unquote_plus('abc%20def'), 'abc def') - self.assertEqual(compat_urllib_parse_unquote_plus('%7e/abc+def'), '~/abc def') + self.assertEqual(urllib.parse.unquote_plus('abc%20def'), 'abc def') + self.assertEqual(urllib.parse.unquote_plus('%7e/abc+def'), '~/abc def') def test_compat_urllib_parse_urlencode(self): self.assertEqual(compat_urllib_parse_urlencode({'abc': 'def'}), 'abc=def') @@ -107,7 +94,7 @@ class TestCompat(unittest.TestCase): compat_etree_fromstring(xml) def test_struct_unpack(self): - self.assertEqual(compat_struct_unpack('!B', b'\x00'), (0,)) + self.assertEqual(struct.unpack('!B', b'\x00'), (0,)) if __name__ == '__main__': |