diff options
author | Jesús <heckyel@hyperbola.info> | 2022-05-17 10:10:39 +0800 |
---|---|---|
committer | Jesús <heckyel@hyperbola.info> | 2022-05-17 10:10:39 +0800 |
commit | 4bbf329feb5a820ac21269fa426c95ca14d7af25 (patch) | |
tree | 2c147a162b4bddc7862ed5895f1f66edd9a675e8 /test/test_youtube_signature.py | |
parent | e21342911839b7796a5c788a7c3f13b06d975c64 (diff) | |
parent | 5faf6528fb701724ac32e0a487f92281c7800bda (diff) | |
download | hypervideo-pre-4bbf329feb5a820ac21269fa426c95ca14d7af25.tar.lz hypervideo-pre-4bbf329feb5a820ac21269fa426c95ca14d7af25.tar.xz hypervideo-pre-4bbf329feb5a820ac21269fa426c95ca14d7af25.zip |
updated from upstream | 17/05/2022 at 10:10
Diffstat (limited to 'test/test_youtube_signature.py')
-rw-r--r-- | test/test_youtube_signature.py | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py index bbbba073f..2c2013295 100644 --- a/test/test_youtube_signature.py +++ b/test/test_youtube_signature.py @@ -1,21 +1,20 @@ #!/usr/bin/env python3 - -from __future__ import unicode_literals - # Allow direct execution +import contextlib import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -import io import re import string - +import urllib.request from test.helper import FakeYDL, is_download_test + +from yt_dlp.compat import compat_str from yt_dlp.extractor import YoutubeIE from yt_dlp.jsinterp import JSInterpreter -from yt_dlp.compat import compat_str, compat_urlretrieve _SIG_TESTS = [ ( @@ -129,11 +128,9 @@ class TestSignature(unittest.TestCase): os.mkdir(self.TESTDATA_DIR) def tearDown(self): - try: + with contextlib.suppress(OSError): for f in os.listdir(self.TESTDATA_DIR): os.remove(f) - except OSError: - pass def t_factory(name, sig_func, url_pattern): @@ -147,8 +144,8 @@ def t_factory(name, sig_func, url_pattern): fn = os.path.join(self.TESTDATA_DIR, basename) if not os.path.exists(fn): - compat_urlretrieve(url, fn) - with io.open(fn, encoding='utf-8') as testf: + urllib.request.urlretrieve(url, fn) + with open(fn, encoding='utf-8') as testf: jscode = testf.read() self.assertEqual(sig_func(jscode, sig_input), expected_sig) |