aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-06-24 16:24:43 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-06-25 00:14:12 +0530
commit14f25df2b6233553e968df023430ca96c0b1df9f (patch)
treec611d59d4462820a9e99726b9179811ed88a35b8 /test
parent54007a45f11ed730352324289b714baefd2901eb (diff)
downloadhypervideo-pre-14f25df2b6233553e968df023430ca96c0b1df9f.tar.lz
hypervideo-pre-14f25df2b6233553e968df023430ca96c0b1df9f.tar.xz
hypervideo-pre-14f25df2b6233553e968df023430ca96c0b1df9f.zip
[compat] Remove deprecated functions from core code
Diffstat (limited to 'test')
-rw-r--r--test/helper.py28
-rw-r--r--test/test_YoutubeDL.py4
-rw-r--r--test/test_compat.py11
-rwxr-xr-xtest/test_download.py3
-rw-r--r--test/test_socks.py7
-rw-r--r--test/test_youtube_signature.py3
6 files changed, 26 insertions, 30 deletions
diff --git a/test/helper.py b/test/helper.py
index 5a389b8c4..f19e1a34f 100644
--- a/test/helper.py
+++ b/test/helper.py
@@ -9,7 +9,7 @@ import types
import yt_dlp.extractor
from yt_dlp import YoutubeDL
-from yt_dlp.compat import compat_os_name, compat_str
+from yt_dlp.compat import compat_os_name
from yt_dlp.utils import preferredencoding, write_string
if 'pytest' in sys.modules:
@@ -96,29 +96,29 @@ md5 = lambda s: hashlib.md5(s.encode()).hexdigest()
def expect_value(self, got, expected, field):
- if isinstance(expected, compat_str) and expected.startswith('re:'):
+ if isinstance(expected, str) and expected.startswith('re:'):
match_str = expected[len('re:'):]
match_rex = re.compile(match_str)
self.assertTrue(
- isinstance(got, compat_str),
- f'Expected a {compat_str.__name__} object, but got {type(got).__name__} for field {field}')
+ isinstance(got, str),
+ f'Expected a {str.__name__} object, but got {type(got).__name__} for field {field}')
self.assertTrue(
match_rex.match(got),
f'field {field} (value: {got!r}) should match {match_str!r}')
- elif isinstance(expected, compat_str) and expected.startswith('startswith:'):
+ elif isinstance(expected, str) and expected.startswith('startswith:'):
start_str = expected[len('startswith:'):]
self.assertTrue(
- isinstance(got, compat_str),
- f'Expected a {compat_str.__name__} object, but got {type(got).__name__} for field {field}')
+ isinstance(got, str),
+ f'Expected a {str.__name__} object, but got {type(got).__name__} for field {field}')
self.assertTrue(
got.startswith(start_str),
f'field {field} (value: {got!r}) should start with {start_str!r}')
- elif isinstance(expected, compat_str) and expected.startswith('contains:'):
+ elif isinstance(expected, str) and expected.startswith('contains:'):
contains_str = expected[len('contains:'):]
self.assertTrue(
- isinstance(got, compat_str),
- f'Expected a {compat_str.__name__} object, but got {type(got).__name__} for field {field}')
+ isinstance(got, str),
+ f'Expected a {str.__name__} object, but got {type(got).__name__} for field {field}')
self.assertTrue(
contains_str in got,
f'field {field} (value: {got!r}) should contain {contains_str!r}')
@@ -142,12 +142,12 @@ def expect_value(self, got, expected, field):
index, field, type_expected, type_got))
expect_value(self, item_got, item_expected, field)
else:
- if isinstance(expected, compat_str) and expected.startswith('md5:'):
+ if isinstance(expected, str) and expected.startswith('md5:'):
self.assertTrue(
- isinstance(got, compat_str),
+ isinstance(got, str),
f'Expected field {field} to be a unicode object, but got value {got!r} of type {type(got)!r}')
got = 'md5:' + md5(got)
- elif isinstance(expected, compat_str) and re.match(r'^(?:min|max)?count:\d+', expected):
+ elif isinstance(expected, str) and re.match(r'^(?:min|max)?count:\d+', expected):
self.assertTrue(
isinstance(got, (list, dict)),
f'Expected field {field} to be a list or a dict, but it is of type {type(got).__name__}')
@@ -236,7 +236,7 @@ def expect_info_dict(self, got_dict, expected_dict):
missing_keys = set(test_info_dict.keys()) - set(expected_dict.keys())
if missing_keys:
def _repr(v):
- if isinstance(v, compat_str):
+ if isinstance(v, str):
return "'%s'" % v.replace('\\', '\\\\').replace("'", "\\'").replace('\n', '\\n')
elif isinstance(v, type):
return v.__name__
diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py
index 44e8f2917..1eb3abc17 100644
--- a/test/test_YoutubeDL.py
+++ b/test/test_YoutubeDL.py
@@ -14,7 +14,7 @@ import urllib.error
from test.helper import FakeYDL, assertRegexpMatches
from yt_dlp import YoutubeDL
-from yt_dlp.compat import compat_os_name, compat_str
+from yt_dlp.compat import compat_os_name
from yt_dlp.extractor import YoutubeIE
from yt_dlp.extractor.common import InfoExtractor
from yt_dlp.postprocessor.common import PostProcessor
@@ -1185,7 +1185,7 @@ class TestYoutubeDL(unittest.TestCase):
def _entries(self):
for n in range(3):
- video_id = compat_str(n)
+ video_id = str(n)
yield {
'_type': 'url_transparent',
'ie_key': VideoIE.ie_key(),
diff --git a/test/test_compat.py b/test/test_compat.py
index a70adfa30..c6a8f4ecb 100644
--- a/test/test_compat.py
+++ b/test/test_compat.py
@@ -15,7 +15,6 @@ from yt_dlp import compat
from yt_dlp.compat import (
compat_etree_fromstring,
compat_expanduser,
- compat_str,
compat_urllib_parse_unquote,
compat_urllib_parse_urlencode,
)
@@ -82,11 +81,11 @@ class TestCompat(unittest.TestCase):
</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"?>
diff --git a/test/test_download.py b/test/test_download.py
index b98ddebcb..b397b3ecf 100755
--- a/test/test_download.py
+++ b/test/test_download.py
@@ -26,7 +26,6 @@ from test.helper import (
)
import yt_dlp.YoutubeDL # isort: split
-from yt_dlp.compat import compat_HTTPError
from yt_dlp.extractor import get_info_extractor
from yt_dlp.utils import (
DownloadError,
@@ -168,7 +167,7 @@ def generator(test_case, tname):
force_generic_extractor=params.get('force_generic_extractor', False))
except (DownloadError, ExtractorError) as err:
# Check if the exception is not a network related one
- if not err.exc_info[0] in (urllib.error.URLError, socket.timeout, UnavailableVideoError, http.client.BadStatusLine) or (err.exc_info[0] == compat_HTTPError and err.exc_info[1].code == 503):
+ if not err.exc_info[0] in (urllib.error.URLError, socket.timeout, UnavailableVideoError, http.client.BadStatusLine) or (err.exc_info[0] == urllib.error.HTTPError and err.exc_info[1].code == 503):
raise
if try_num == RETRIES:
diff --git a/test/test_socks.py b/test/test_socks.py
index 159faf58e..6651290d2 100644
--- a/test/test_socks.py
+++ b/test/test_socks.py
@@ -13,7 +13,6 @@ import subprocess
import urllib.request
from test.helper import FakeYDL, get_params, is_download_test
-from yt_dlp.compat import compat_str
@is_download_test
@@ -102,13 +101,13 @@ class TestSocks(unittest.TestCase):
return ydl.urlopen('http://yt-dl.org/ip').read().decode()
def test_socks4(self):
- self.assertTrue(isinstance(self._get_ip('socks4'), compat_str))
+ self.assertTrue(isinstance(self._get_ip('socks4'), str))
def test_socks4a(self):
- self.assertTrue(isinstance(self._get_ip('socks4a'), compat_str))
+ self.assertTrue(isinstance(self._get_ip('socks4a'), str))
def test_socks5(self):
- self.assertTrue(isinstance(self._get_ip('socks5'), compat_str))
+ self.assertTrue(isinstance(self._get_ip('socks5'), str))
if __name__ == '__main__':
diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py
index 56304772b..4fc2917e5 100644
--- a/test/test_youtube_signature.py
+++ b/test/test_youtube_signature.py
@@ -14,7 +14,6 @@ import string
import urllib.request
from test.helper import FakeYDL, is_download_test
-from yt_dlp.compat import compat_str
from yt_dlp.extractor import YoutubeIE
from yt_dlp.jsinterp import JSInterpreter
@@ -159,7 +158,7 @@ def t_factory(name, sig_func, url_pattern):
def signature(jscode, sig_input):
func = YoutubeIE(FakeYDL())._parse_sig_js(jscode)
src_sig = (
- compat_str(string.printable[:sig_input])
+ str(string.printable[:sig_input])
if isinstance(sig_input, int) else sig_input)
return func(src_sig)