aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorpukkandan <pukkandan.ytdlp@gmail.com>2022-05-09 17:24:28 +0530
committerpukkandan <pukkandan.ytdlp@gmail.com>2022-05-09 17:59:26 +0530
commit0f06bcd7591332937fdec497d6cbb4914358bc79 (patch)
treed202c952782c1ea96277f60ca55dcb182e0a1916 /test
parentd239db030671b9445c77c7d8cb190ba5fee76b96 (diff)
downloadhypervideo-pre-0f06bcd7591332937fdec497d6cbb4914358bc79.tar.lz
hypervideo-pre-0f06bcd7591332937fdec497d6cbb4914358bc79.tar.xz
hypervideo-pre-0f06bcd7591332937fdec497d6cbb4914358bc79.zip
[cleanup] Minor fixes (See desc)
* [youtube] Fix `--youtube-skip-dash-manifest` * [build] Use `$()` in `Makefile`. Closes #3684 * Fix bug in 385ffb467b2285e85a2a5495b90314ba1f8e0700 * Fix bug in 43d7f5a5d0c77556156a3f8caa6976d3908a1e38 * [cleanup] Remove unnecessary `utf-8` from `str.encode`/`bytes.decode` * [utils] LazyList: Expose unnecessarily "protected" attributes and other minor cleanup
Diffstat (limited to 'test')
-rw-r--r--test/helper.py2
-rw-r--r--test/test_InfoExtractor.py8
-rw-r--r--test/test_YoutubeDLCookieJar.py2
-rw-r--r--test/test_aes.py8
-rw-r--r--test/test_compat.py2
-rw-r--r--test/test_http.py8
-rw-r--r--test/test_socks.py10
-rw-r--r--test/test_subtitles.py2
-rw-r--r--test/test_update.py.disabled2
-rw-r--r--test/test_utils.py2
10 files changed, 23 insertions, 23 deletions
diff --git a/test/helper.py b/test/helper.py
index 81e53ed74..2333ace98 100644
--- a/test/helper.py
+++ b/test/helper.py
@@ -92,7 +92,7 @@ def gettestcases(include_onlymatching=False):
yield from ie.get_testcases(include_onlymatching)
-md5 = lambda s: hashlib.md5(s.encode('utf-8')).hexdigest()
+md5 = lambda s: hashlib.md5(s.encode()).hexdigest()
def expect_value(self, got, expected, field):
diff --git a/test/test_InfoExtractor.py b/test/test_InfoExtractor.py
index 173b62920..257ea7dd3 100644
--- a/test/test_InfoExtractor.py
+++ b/test/test_InfoExtractor.py
@@ -1360,7 +1360,7 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
for mpd_file, mpd_url, mpd_base_url, expected_formats, expected_subtitles in _TEST_CASES:
with open('./test/testdata/mpd/%s.mpd' % mpd_file, encoding='utf-8') as f:
formats, subtitles = self.ie._parse_mpd_formats_and_subtitles(
- compat_etree_fromstring(f.read().encode('utf-8')),
+ compat_etree_fromstring(f.read().encode()),
mpd_base_url=mpd_base_url, mpd_url=mpd_url)
self.ie._sort_formats(formats)
expect_value(self, formats, expected_formats, None)
@@ -1551,7 +1551,7 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
for ism_file, ism_url, expected_formats, expected_subtitles in _TEST_CASES:
with open('./test/testdata/ism/%s.Manifest' % ism_file, encoding='utf-8') as f:
formats, subtitles = self.ie._parse_ism_formats_and_subtitles(
- compat_etree_fromstring(f.read().encode('utf-8')), ism_url=ism_url)
+ compat_etree_fromstring(f.read().encode()), ism_url=ism_url)
self.ie._sort_formats(formats)
expect_value(self, formats, expected_formats, None)
expect_value(self, subtitles, expected_subtitles, None)
@@ -1577,7 +1577,7 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
for f4m_file, f4m_url, expected_formats in _TEST_CASES:
with open('./test/testdata/f4m/%s.f4m' % f4m_file, encoding='utf-8') as f:
formats = self.ie._parse_f4m_formats(
- compat_etree_fromstring(f.read().encode('utf-8')),
+ compat_etree_fromstring(f.read().encode()),
f4m_url, None)
self.ie._sort_formats(formats)
expect_value(self, formats, expected_formats, None)
@@ -1624,7 +1624,7 @@ jwplayer("mediaplayer").setup({"abouttext":"Visit Indie DB","aboutlink":"http:\/
for xspf_file, xspf_url, expected_entries in _TEST_CASES:
with open('./test/testdata/xspf/%s.xspf' % xspf_file, encoding='utf-8') as f:
entries = self.ie._parse_xspf(
- compat_etree_fromstring(f.read().encode('utf-8')),
+ compat_etree_fromstring(f.read().encode()),
xspf_file, xspf_url=xspf_url, xspf_base_url=xspf_url)
expect_value(self, entries, expected_entries, None)
for i in range(len(entries)):
diff --git a/test/test_YoutubeDLCookieJar.py b/test/test_YoutubeDLCookieJar.py
index 13a4569b2..6280e1f2c 100644
--- a/test/test_YoutubeDLCookieJar.py
+++ b/test/test_YoutubeDLCookieJar.py
@@ -17,7 +17,7 @@ class TestYoutubeDLCookieJar(unittest.TestCase):
tf = tempfile.NamedTemporaryFile(delete=False)
try:
cookiejar.save(filename=tf.name, ignore_discard=True, ignore_expires=True)
- temp = tf.read().decode('utf-8')
+ temp = tf.read().decode()
self.assertTrue(re.search(
r'www\.foobar\.foobar\s+FALSE\s+/\s+TRUE\s+0\s+YoutubeDLExpiresEmpty\s+YoutubeDLExpiresEmptyValue', temp))
self.assertTrue(re.search(
diff --git a/test/test_aes.py b/test/test_aes.py
index c934104e3..2b7b7cf54 100644
--- a/test/test_aes.py
+++ b/test/test_aes.py
@@ -81,19 +81,19 @@ class TestAES(unittest.TestCase):
self.assertEqual(decrypted.rstrip(b'\x08'), self.secret_msg)
def test_decrypt_text(self):
- password = intlist_to_bytes(self.key).decode('utf-8')
+ password = intlist_to_bytes(self.key).decode()
encrypted = base64.b64encode(
intlist_to_bytes(self.iv[:8])
+ b'\x17\x15\x93\xab\x8d\x80V\xcdV\xe0\t\xcdo\xc2\xa5\xd8ksM\r\xe27N\xae'
- ).decode('utf-8')
+ ).decode()
decrypted = (aes_decrypt_text(encrypted, password, 16))
self.assertEqual(decrypted, self.secret_msg)
- password = intlist_to_bytes(self.key).decode('utf-8')
+ password = intlist_to_bytes(self.key).decode()
encrypted = base64.b64encode(
intlist_to_bytes(self.iv[:8])
+ b'\x0b\xe6\xa4\xd9z\x0e\xb8\xb9\xd0\xd4i_\x85\x1d\x99\x98_\xe5\x80\xe7.\xbf\xa5\x83'
- ).decode('utf-8')
+ ).decode()
decrypted = (aes_decrypt_text(encrypted, password, 32))
self.assertEqual(decrypted, self.secret_msg)
diff --git a/test/test_compat.py b/test/test_compat.py
index 9b185853d..224175c65 100644
--- a/test/test_compat.py
+++ b/test/test_compat.py
@@ -90,7 +90,7 @@ class TestCompat(unittest.TestCase):
<foo><bar>spam</bar></foo>
</root>
'''
- doc = compat_etree_fromstring(xml.encode('utf-8'))
+ 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))
diff --git a/test/test_http.py b/test/test_http.py
index fb8c9f4e9..664e09ace 100644
--- a/test/test_http.py
+++ b/test/test_http.py
@@ -140,7 +140,7 @@ def _build_proxy_handler(name):
self.send_response(200)
self.send_header('Content-Type', 'text/plain; charset=utf-8')
self.end_headers()
- self.wfile.write('{self.proxy_name}: {self.path}'.format(self=self).encode('utf-8'))
+ self.wfile.write('{self.proxy_name}: {self.path}'.format(self=self).encode())
return HTTPTestRequestHandler
@@ -167,12 +167,12 @@ class TestProxy(unittest.TestCase):
'geo_verification_proxy': geo_proxy,
})
url = 'http://foo.com/bar'
- response = ydl.urlopen(url).read().decode('utf-8')
+ response = ydl.urlopen(url).read().decode()
self.assertEqual(response, f'normal: {url}')
req = compat_urllib_request.Request(url)
req.add_header('Ytdl-request-proxy', geo_proxy)
- response = ydl.urlopen(req).read().decode('utf-8')
+ response = ydl.urlopen(req).read().decode()
self.assertEqual(response, f'geo: {url}')
def test_proxy_with_idn(self):
@@ -180,7 +180,7 @@ class TestProxy(unittest.TestCase):
'proxy': f'127.0.0.1:{self.port}',
})
url = 'http://中文.tw/'
- response = ydl.urlopen(url).read().decode('utf-8')
+ response = ydl.urlopen(url).read().decode()
# b'xn--fiq228c' is '中文'.encode('idna')
self.assertEqual(response, 'normal: http://xn--fiq228c.tw/')
diff --git a/test/test_socks.py b/test/test_socks.py
index 546f0d73d..a8b068cdd 100644
--- a/test/test_socks.py
+++ b/test/test_socks.py
@@ -32,7 +32,7 @@ class TestMultipleSocks(unittest.TestCase):
'proxy': params['primary_proxy']
})
self.assertEqual(
- ydl.urlopen('http://yt-dl.org/ip').read().decode('utf-8'),
+ ydl.urlopen('http://yt-dl.org/ip').read().decode(),
params['primary_server_ip'])
def test_proxy_https(self):
@@ -43,7 +43,7 @@ class TestMultipleSocks(unittest.TestCase):
'proxy': params['primary_proxy']
})
self.assertEqual(
- ydl.urlopen('https://yt-dl.org/ip').read().decode('utf-8'),
+ ydl.urlopen('https://yt-dl.org/ip').read().decode(),
params['primary_server_ip'])
def test_secondary_proxy_http(self):
@@ -54,7 +54,7 @@ class TestMultipleSocks(unittest.TestCase):
req = compat_urllib_request.Request('http://yt-dl.org/ip')
req.add_header('Ytdl-request-proxy', params['secondary_proxy'])
self.assertEqual(
- ydl.urlopen(req).read().decode('utf-8'),
+ ydl.urlopen(req).read().decode(),
params['secondary_server_ip'])
def test_secondary_proxy_https(self):
@@ -65,7 +65,7 @@ class TestMultipleSocks(unittest.TestCase):
req = compat_urllib_request.Request('https://yt-dl.org/ip')
req.add_header('Ytdl-request-proxy', params['secondary_proxy'])
self.assertEqual(
- ydl.urlopen(req).read().decode('utf-8'),
+ ydl.urlopen(req).read().decode(),
params['secondary_server_ip'])
@@ -96,7 +96,7 @@ class TestSocks(unittest.TestCase):
ydl = FakeYDL({
'proxy': '%s://127.0.0.1:%d' % (protocol, self.port),
})
- return ydl.urlopen('http://yt-dl.org/ip').read().decode('utf-8')
+ return ydl.urlopen('http://yt-dl.org/ip').read().decode()
def test_socks4(self):
self.assertTrue(isinstance(self._get_ip('socks4'), compat_str))
diff --git a/test/test_subtitles.py b/test/test_subtitles.py
index 362b67cef..182bd7a4b 100644
--- a/test/test_subtitles.py
+++ b/test/test_subtitles.py
@@ -51,7 +51,7 @@ class BaseTestSubtitles(unittest.TestCase):
for sub_info in subtitles.values():
if sub_info.get('data') is None:
uf = self.DL.urlopen(sub_info['url'])
- sub_info['data'] = uf.read().decode('utf-8')
+ sub_info['data'] = uf.read().decode()
return {l: sub_info['data'] for l, sub_info in subtitles.items()}
diff --git a/test/test_update.py.disabled b/test/test_update.py.disabled
index 389b8ffe5..73b55cdac 100644
--- a/test/test_update.py.disabled
+++ b/test/test_update.py.disabled
@@ -21,7 +21,7 @@ class TestUpdate(unittest.TestCase):
signature = versions_info['signature']
del versions_info['signature']
self.assertTrue(rsa_verify(
- json.dumps(versions_info, sort_keys=True).encode('utf-8'),
+ json.dumps(versions_info, sort_keys=True).encode(),
signature, UPDATES_RSA_KEY))
diff --git a/test/test_utils.py b/test/test_utils.py
index 5e220087b..184c39cff 100644
--- a/test/test_utils.py
+++ b/test/test_utils.py
@@ -1759,7 +1759,7 @@ Line 1
def test(ll, idx, val, cache):
self.assertEqual(ll[idx], val)
- self.assertEqual(getattr(ll, '_LazyList__cache'), list(cache))
+ self.assertEqual(ll._cache, list(cache))
ll = LazyList(range(10))
test(ll, 0, 0, range(1))