mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-07-03 04:22:53 -05:00
[compat, networking] Deprecate old functions (#2861)
Authored by: coletdjnz, pukkandan
This commit is contained in:
@ -1057,14 +1057,15 @@ 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
|
||||
|
||||
req = ydl.urlopen(urllib_req).request
|
||||
assert req.url == urllib_req.get_full_url()
|
||||
assert req.data == urllib_req.data
|
||||
assert req.method == urllib_req.get_method()
|
||||
assert 'X-Test' in req.headers
|
||||
assert 'Cookie' in req.headers
|
||||
assert req.extensions.get('timeout') == 2
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', category=DeprecationWarning)
|
||||
req = ydl.urlopen(urllib_req).request
|
||||
assert req.url == urllib_req.get_full_url()
|
||||
assert req.data == urllib_req.data
|
||||
assert req.method == urllib_req.get_method()
|
||||
assert 'X-Test' in req.headers
|
||||
assert 'Cookie' in req.headers
|
||||
assert req.extensions.get('timeout') == 2
|
||||
|
||||
with pytest.raises(AssertionError):
|
||||
ydl.urlopen(None)
|
||||
@ -1362,7 +1363,9 @@ class TestResponse:
|
||||
|
||||
def test_compat(self):
|
||||
res = Response(io.BytesIO(b''), url='test://', status=404, headers={'test': 'test'})
|
||||
assert res.code == res.getcode() == res.status
|
||||
assert res.geturl() == res.url
|
||||
assert res.info() is res.headers
|
||||
assert res.getheader('test') == res.get_header('test')
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter('ignore', category=DeprecationWarning)
|
||||
assert res.code == res.getcode() == res.status
|
||||
assert res.geturl() == res.url
|
||||
assert res.info() is res.headers
|
||||
assert res.getheader('test') == res.get_header('test')
|
||||
|
Reference in New Issue
Block a user