mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-10-26 16:51:00 +09:00
Remove Python 3.10 support (#17160)
* Also upgrade Windows builds to Python 3.14 Closes #16916, Closes #16917 Authored by: bashonly, doe1080, Grub4K Co-authored-by: doe1080 <98906116+doe1080@users.noreply.github.com> Co-authored-by: Simon Sawicki <contact@grub4k.dev>
This commit is contained in:
54 files changed
+124
-1645
No files matched your search
+11
-15
@@ -12,9 +12,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
|
||||
import struct
|
||||
|
||||
from yt_dlp import compat
|
||||
from yt_dlp.compat import urllib # isort: split
|
||||
from yt_dlp.compat import compat_etree_fromstring, compat_expanduser, compat_datetime_from_timestamp
|
||||
from yt_dlp.compat.urllib.request import getproxies
|
||||
|
||||
|
||||
class TestCompat(unittest.TestCase):
|
||||
@@ -22,8 +20,6 @@ class TestCompat(unittest.TestCase):
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
_ = compat.compat_basestring
|
||||
|
||||
self.assertEqual(urllib.request.getproxies, getproxies)
|
||||
|
||||
with self.assertWarns(DeprecationWarning):
|
||||
_ = compat.compat_pycrypto_AES # Must not raise error
|
||||
|
||||
@@ -63,41 +59,41 @@ class TestCompat(unittest.TestCase):
|
||||
def test_compat_datetime_from_timestamp(self):
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(0),
|
||||
dt.datetime(1970, 1, 1, 0, 0, 0, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1970, 1, 1, 0, 0, 0, tzinfo=dt.UTC))
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(1),
|
||||
dt.datetime(1970, 1, 1, 0, 0, 1, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1970, 1, 1, 0, 0, 1, tzinfo=dt.UTC))
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(3600),
|
||||
dt.datetime(1970, 1, 1, 1, 0, 0, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1970, 1, 1, 1, 0, 0, tzinfo=dt.UTC))
|
||||
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(-1),
|
||||
dt.datetime(1969, 12, 31, 23, 59, 59, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1969, 12, 31, 23, 59, 59, tzinfo=dt.UTC))
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(-86400),
|
||||
dt.datetime(1969, 12, 31, 0, 0, 0, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1969, 12, 31, 0, 0, 0, tzinfo=dt.UTC))
|
||||
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(0.5),
|
||||
dt.datetime(1970, 1, 1, 0, 0, 0, 500000, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1970, 1, 1, 0, 0, 0, 500000, tzinfo=dt.UTC))
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(1.000001),
|
||||
dt.datetime(1970, 1, 1, 0, 0, 1, 1, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1970, 1, 1, 0, 0, 1, 1, tzinfo=dt.UTC))
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(-1.25),
|
||||
dt.datetime(1969, 12, 31, 23, 59, 58, 750000, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1969, 12, 31, 23, 59, 58, 750000, tzinfo=dt.UTC))
|
||||
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(-1577923200),
|
||||
dt.datetime(1920, 1, 1, 0, 0, 0, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1920, 1, 1, 0, 0, 0, tzinfo=dt.UTC))
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(4102444800),
|
||||
dt.datetime(2100, 1, 1, 0, 0, 0, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(2100, 1, 1, 0, 0, 0, tzinfo=dt.UTC))
|
||||
|
||||
self.assertEqual(
|
||||
compat_datetime_from_timestamp(173568960000),
|
||||
dt.datetime(7470, 3, 8, 0, 0, 0, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(7470, 3, 8, 0, 0, 0, tzinfo=dt.UTC))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
@@ -163,7 +163,7 @@ class TestCookies(unittest.TestCase):
|
||||
self.assertEqual(cookie.name, 'foo')
|
||||
self.assertEqual(cookie.value, 'test%20%3Bcookie')
|
||||
self.assertFalse(cookie.secure)
|
||||
expected_expiration = dt.datetime(2021, 6, 18, 21, 39, 19, tzinfo=dt.timezone.utc)
|
||||
expected_expiration = dt.datetime(2021, 6, 18, 21, 39, 19, tzinfo=dt.UTC)
|
||||
self.assertEqual(cookie.expires, int(expected_expiration.timestamp()))
|
||||
|
||||
def test_pbkdf2_sha1(self):
|
||||
|
||||
@@ -53,7 +53,7 @@ TEST_CASES_EQUALS = [{
|
||||
}, {
|
||||
'name': 'Date',
|
||||
'unparsed': [['Date', '2001-09-09T01:46:40.000Z']],
|
||||
'parsed': dt.datetime.fromtimestamp(1e9, tz=dt.timezone.utc),
|
||||
'parsed': dt.datetime.fromtimestamp(1e9, tz=dt.UTC),
|
||||
}, {
|
||||
'name': 'Array',
|
||||
'unparsed': [[1, 2, 3], 'a', 'b', 'c'],
|
||||
|
||||
@@ -55,7 +55,7 @@ class YoutubeDL(yt_dlp.YoutubeDL):
|
||||
|
||||
def _file_md5(fn):
|
||||
with open(fn, 'rb') as f:
|
||||
return hashlib.md5(f.read()).hexdigest()
|
||||
return hashlib.file_digest(f, hashlib.md5).hexdigest()
|
||||
|
||||
|
||||
normal_test_cases = gettestcases()
|
||||
|
||||
@@ -1683,8 +1683,7 @@ class TestYoutubeDLNetworking:
|
||||
|
||||
def test_compat_opener(self):
|
||||
with FakeYDL() as ydl:
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', category=DeprecationWarning)
|
||||
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
|
||||
assert isinstance(ydl._opener, urllib.request.OpenerDirector)
|
||||
|
||||
@pytest.mark.parametrize('proxy,expected', [
|
||||
@@ -1703,8 +1702,7 @@ class TestYoutubeDLNetworking:
|
||||
urllib_req = urllib.request.Request('http://foo.bar', data=b'test', method='PUT', headers={'X-Test': '1'})
|
||||
urllib_req.add_unredirected_header('Cookie', 'bob=bob')
|
||||
urllib_req.timeout = 2
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', category=DeprecationWarning)
|
||||
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
|
||||
req = ydl.urlopen(urllib_req).request
|
||||
assert req.url == urllib_req.get_full_url()
|
||||
assert req.data == urllib_req.data
|
||||
@@ -2123,8 +2121,7 @@ class TestResponse:
|
||||
|
||||
def test_compat(self):
|
||||
res = Response(io.BytesIO(b''), url='test://', status=404, headers={'test': 'test'})
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', category=DeprecationWarning)
|
||||
with warnings.catch_warnings(action='ignore', category=DeprecationWarning):
|
||||
assert res.code == res.getcode() == res.status
|
||||
assert res.geturl() == res.url
|
||||
assert res.info() is res.headers
|
||||
|
||||
+6
-7
@@ -426,15 +426,15 @@ class TestUtil(unittest.TestCase):
|
||||
|
||||
def test_datetime_round(self):
|
||||
self.assertEqual(datetime_round(dt.datetime.strptime('1820-05-12T01:23:45Z', '%Y-%m-%dT%H:%M:%SZ')),
|
||||
dt.datetime(1820, 5, 12, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1820, 5, 12, tzinfo=dt.UTC))
|
||||
self.assertEqual(datetime_round(dt.datetime.strptime('1969-12-31T23:34:45Z', '%Y-%m-%dT%H:%M:%SZ'), 'hour'),
|
||||
dt.datetime(1970, 1, 1, 0, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(1970, 1, 1, 0, tzinfo=dt.UTC))
|
||||
self.assertEqual(datetime_round(dt.datetime.strptime('2024-12-25T01:23:45Z', '%Y-%m-%dT%H:%M:%SZ'), 'minute'),
|
||||
dt.datetime(2024, 12, 25, 1, 24, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(2024, 12, 25, 1, 24, tzinfo=dt.UTC))
|
||||
self.assertEqual(datetime_round(dt.datetime.strptime('2024-12-25T01:23:45.123Z', '%Y-%m-%dT%H:%M:%S.%fZ'), 'second'),
|
||||
dt.datetime(2024, 12, 25, 1, 23, 45, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(2024, 12, 25, 1, 23, 45, tzinfo=dt.UTC))
|
||||
self.assertEqual(datetime_round(dt.datetime.strptime('2024-12-25T01:23:45.678Z', '%Y-%m-%dT%H:%M:%S.%fZ'), 'second'),
|
||||
dt.datetime(2024, 12, 25, 1, 23, 46, tzinfo=dt.timezone.utc))
|
||||
dt.datetime(2024, 12, 25, 1, 23, 46, tzinfo=dt.UTC))
|
||||
|
||||
def test_strftime_or_none(self):
|
||||
self.assertEqual(strftime_or_none(-4722192000), '18200512')
|
||||
@@ -2177,8 +2177,7 @@ Line 1
|
||||
self.assertEqual(variadic(None), (None, ))
|
||||
self.assertEqual(variadic('spam'), ('spam', ))
|
||||
self.assertEqual(variadic('spam', allowed_types=dict), 'spam')
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore')
|
||||
with warnings.catch_warnings(action='ignore'):
|
||||
self.assertEqual(variadic('spam', allowed_types=[dict]), 'spam')
|
||||
|
||||
def test_http_header_dict(self):
|
||||
|
||||
Reference in new issue
Block a user