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:
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}')
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__}')
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__