aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_download.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_download.py')
-rwxr-xr-xtest/test_download.py29
1 files changed, 12 insertions, 17 deletions
diff --git a/test/test_download.py b/test/test_download.py
index 818a670fb..9a83bee2f 100755
--- a/test/test_download.py
+++ b/test/test_download.py
@@ -1,11 +1,12 @@
#!/usr/bin/env python3
-
-from __future__ import unicode_literals
-
# Allow direct execution
+import hashlib
+import json
import os
+import socket
import sys
import unittest
+
sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
from test.helper import (
@@ -19,25 +20,19 @@ from test.helper import (
try_rm,
)
-
-import hashlib
-import io
-import json
-import socket
-
import yt_dlp.YoutubeDL
from yt_dlp.compat import (
compat_http_client,
- compat_urllib_error,
compat_HTTPError,
+ compat_urllib_error,
)
+from yt_dlp.extractor import get_info_extractor
from yt_dlp.utils import (
DownloadError,
ExtractorError,
- format_bytes,
UnavailableVideoError,
+ format_bytes,
)
-from yt_dlp.extractor import get_info_extractor
RETRIES = 3
@@ -46,7 +41,7 @@ class YoutubeDL(yt_dlp.YoutubeDL):
def __init__(self, *args, **kwargs):
self.to_stderr = self.to_screen
self.processed_info_dicts = []
- super(YoutubeDL, self).__init__(*args, **kwargs)
+ super().__init__(*args, **kwargs)
def report_warning(self, message):
# Don't accept warnings during tests
@@ -54,7 +49,7 @@ class YoutubeDL(yt_dlp.YoutubeDL):
def process_info(self, info_dict):
self.processed_info_dicts.append(info_dict.copy())
- return super(YoutubeDL, self).process_info(info_dict)
+ return super().process_info(info_dict)
def _file_md5(fn):
@@ -80,7 +75,7 @@ class TestDownload(unittest.TestCase):
def strclass(cls):
"""From 2.7's unittest; 2.6 had _strclass so we can't import it."""
- return '%s.%s' % (cls.__module__, cls.__name__)
+ return f'{cls.__module__}.{cls.__name__}'
add_ie = getattr(self, self._testMethodName).add_ie
return '%s (%s)%s:' % (self._testMethodName,
@@ -179,7 +174,7 @@ def generator(test_case, tname):
report_warning('%s failed due to network errors, skipping...' % tname)
return
- print('Retrying: {0} failed tries\n\n##########\n\n'.format(try_num))
+ print(f'Retrying: {try_num} failed tries\n\n##########\n\n')
try_num += 1
else:
@@ -245,7 +240,7 @@ def generator(test_case, tname):
self.assertTrue(
os.path.exists(info_json_fn),
'Missing info file %s' % info_json_fn)
- with io.open(info_json_fn, encoding='utf-8') as infof:
+ with open(info_json_fn, encoding='utf-8') as infof:
info_dict = json.load(infof)
expect_info_dict(self, info_dict, tc.get('info_dict', {}))
finally: