]> jfr.im git - yt-dlp.git/blobdiff - test/test_compat.py
[build] Exclude `requests` from `py2exe` (#9982)
[yt-dlp.git] / test / test_compat.py
index 62bf5a306250d0f94cfc238ae008b64a9087677d..71ca7f99f10c50d28817d2959b673feb5ae88cf8 100644 (file)
@@ -1,4 +1,5 @@
 #!/usr/bin/env python3
+
 # Allow direct execution
 import os
 import sys
@@ -8,16 +9,16 @@
 
 
 import struct
-import urllib.parse
 
 from yt_dlp import compat
+from yt_dlp.compat import urllib  # isort: split
 from yt_dlp.compat import (
     compat_etree_fromstring,
     compat_expanduser,
-    compat_str,
     compat_urllib_parse_unquote,
     compat_urllib_parse_urlencode,
 )
+from yt_dlp.compat.urllib.request import getproxies
 
 
 class TestCompat(unittest.TestCase):
@@ -28,7 +29,10 @@ def test_compat_passthrough(self):
         with self.assertWarns(DeprecationWarning):
             compat.WINDOWS_VT_MODE
 
-        compat.asyncio.events  # Must not raise error
+        self.assertEqual(urllib.request.getproxies, getproxies)
+
+        with self.assertWarns(DeprecationWarning):
+            compat.compat_pycrypto_AES  # Must not raise error
 
     def test_compat_expanduser(self):
         old_home = os.environ.get('HOME')
@@ -81,11 +85,11 @@ def test_compat_etree_fromstring(self):
             </root>
         '''
         doc = compat_etree_fromstring(xml.encode())
-        self.assertTrue(isinstance(doc.attrib['foo'], compat_str))
-        self.assertTrue(isinstance(doc.attrib['spam'], compat_str))
-        self.assertTrue(isinstance(doc.find('normal').text, compat_str))
-        self.assertTrue(isinstance(doc.find('chinese').text, compat_str))
-        self.assertTrue(isinstance(doc.find('foo/bar').text, compat_str))
+        self.assertTrue(isinstance(doc.attrib['foo'], str))
+        self.assertTrue(isinstance(doc.attrib['spam'], str))
+        self.assertTrue(isinstance(doc.find('normal').text, str))
+        self.assertTrue(isinstance(doc.find('chinese').text, str))
+        self.assertTrue(isinstance(doc.find('foo/bar').text, str))
 
     def test_compat_etree_fromstring_doctype(self):
         xml = '''<?xml version="1.0"?>