diff options
author | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-04-12 04:02:57 +0530 |
---|---|---|
committer | pukkandan <pukkandan.ytdlp@gmail.com> | 2022-04-12 05:32:52 +0530 |
commit | f82711587cee043cb2496fe180b5cc0e07c06eda (patch) | |
tree | 9c6bf7952657a78a93200fc7d90013990fdc8585 /test | |
parent | 86e5f3ed2e6e71eb81ea4c9e26288f16119ffd0c (diff) | |
download | hypervideo-pre-f82711587cee043cb2496fe180b5cc0e07c06eda.tar.lz hypervideo-pre-f82711587cee043cb2496fe180b5cc0e07c06eda.tar.xz hypervideo-pre-f82711587cee043cb2496fe180b5cc0e07c06eda.zip |
[cleanup] Sort imports
Using https://github.com/PyCQA/isort
isort -m VERTICAL_HANGING_INDENT --py 36 -l 80 --rr -n --tc .
Diffstat (limited to 'test')
29 files changed, 156 insertions, 139 deletions
diff --git a/test/helper.py b/test/helper.py index d940e327c..81e53ed74 100644 --- a/test/helper.py +++ b/test/helper.py @@ -3,21 +3,14 @@ import hashlib import json import os.path import re -import types import ssl import sys +import types import yt_dlp.extractor from yt_dlp import YoutubeDL -from yt_dlp.compat import ( - compat_os_name, - compat_str, -) -from yt_dlp.utils import ( - preferredencoding, - write_string, -) - +from yt_dlp.compat import compat_os_name, compat_str +from yt_dlp.utils import preferredencoding, write_string if 'pytest' in sys.modules: import pytest diff --git a/test/test_InfoExtractor.py b/test/test_InfoExtractor.py index 4fd21bed4..173b62920 100644 --- a/test/test_InfoExtractor.py +++ b/test/test_InfoExtractor.py @@ -3,15 +3,21 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +import threading from test.helper import FakeYDL, expect_dict, expect_value, http_server_port + from yt_dlp.compat import compat_etree_fromstring, compat_http_server -from yt_dlp.extractor.common import InfoExtractor from yt_dlp.extractor import YoutubeIE, get_info_extractor -from yt_dlp.utils import encode_data_uri, strip_jsonp, ExtractorError, RegexNotFoundError -import threading - +from yt_dlp.extractor.common import InfoExtractor +from yt_dlp.utils import ( + ExtractorError, + RegexNotFoundError, + encode_data_uri, + strip_jsonp, +) TEAPOT_RESPONSE_STATUS = 418 TEAPOT_RESPONSE_BODY = "<h1>418 I'm a teapot</h1>" diff --git a/test/test_YoutubeDL.py b/test/test_YoutubeDL.py index 480c7539c..051a203ac 100644 --- a/test/test_YoutubeDL.py +++ b/test/test_YoutubeDL.py @@ -3,18 +3,29 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import copy import json - from test.helper import FakeYDL, assertRegexpMatches + from yt_dlp import YoutubeDL -from yt_dlp.compat import compat_os_name, compat_setenv, compat_str, compat_urllib_error +from yt_dlp.compat import ( + compat_os_name, + compat_setenv, + compat_str, + compat_urllib_error, +) from yt_dlp.extractor import YoutubeIE from yt_dlp.extractor.common import InfoExtractor from yt_dlp.postprocessor.common import PostProcessor -from yt_dlp.utils import ExtractorError, int_or_none, match_filter_func, LazyList +from yt_dlp.utils import ( + ExtractorError, + LazyList, + int_or_none, + match_filter_func, +) TEST_URL = 'http://localhost/sample.mp4' diff --git a/test/test_YoutubeDLCookieJar.py b/test/test_YoutubeDLCookieJar.py index 1e5bedcae..13a4569b2 100644 --- a/test/test_YoutubeDLCookieJar.py +++ b/test/test_YoutubeDLCookieJar.py @@ -4,6 +4,7 @@ import re import sys import tempfile import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from yt_dlp.utils import YoutubeDLCookieJar diff --git a/test/test_aes.py b/test/test_aes.py index 34584a04f..1c1238c8b 100644 --- a/test/test_aes.py +++ b/test/test_aes.py @@ -3,26 +3,28 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +import base64 + from yt_dlp.aes import ( - aes_decrypt, - aes_encrypt, - aes_ecb_encrypt, - aes_ecb_decrypt, + BLOCK_SIZE_BYTES, aes_cbc_decrypt, aes_cbc_decrypt_bytes, aes_cbc_encrypt, aes_ctr_decrypt, aes_ctr_encrypt, + aes_decrypt, + aes_decrypt_text, + aes_ecb_decrypt, + aes_ecb_encrypt, + aes_encrypt, aes_gcm_decrypt_and_verify, aes_gcm_decrypt_and_verify_bytes, - aes_decrypt_text, - BLOCK_SIZE_BYTES, ) from yt_dlp.compat import compat_pycrypto_AES from yt_dlp.utils import bytes_to_intlist, intlist_to_bytes -import base64 # the encrypted data can be generate with 'devscripts/generate_aes_testdata.py' diff --git a/test/test_age_restriction.py b/test/test_age_restriction.py index 50d16a729..e1012f69b 100644 --- a/test/test_age_restriction.py +++ b/test/test_age_restriction.py @@ -3,9 +3,10 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from test.helper import try_rm, is_download_test +from test.helper import is_download_test, try_rm from yt_dlp import YoutubeDL diff --git a/test/test_all_urls.py b/test/test_all_urls.py index d70da8cae..b6019554e 100644 --- a/test/test_all_urls.py +++ b/test/test_all_urls.py @@ -1,19 +1,16 @@ #!/usr/bin/env python3 # Allow direct execution +import collections import os import sys import unittest -import collections + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from test.helper import gettestcases -from yt_dlp.extractor import ( - FacebookIE, - gen_extractors, - YoutubeIE, -) +from yt_dlp.extractor import FacebookIE, YoutubeIE, gen_extractors class TestAllURLsMatching(unittest.TestCase): diff --git a/test/test_cache.py b/test/test_cache.py index 4e4641eba..14e54ba20 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -1,14 +1,15 @@ #!/usr/bin/env python3 -import shutil - # Allow direct execution import os +import shutil import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from test.helper import FakeYDL + from yt_dlp.cache import Cache diff --git a/test/test_compat.py b/test/test_compat.py index 31524c5ab..20dab9573 100644 --- a/test/test_compat.py +++ b/test/test_compat.py @@ -3,14 +3,15 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from yt_dlp.compat import ( - compat_getenv, - compat_setenv, compat_etree_fromstring, compat_expanduser, + compat_getenv, + compat_setenv, compat_str, compat_struct_unpack, compat_urllib_parse_unquote, diff --git a/test/test_cookies.py b/test/test_cookies.py index 842ebcb99..5bfaec367 100644 --- a/test/test_cookies.py +++ b/test/test_cookies.py @@ -6,10 +6,10 @@ from yt_dlp.cookies import ( LinuxChromeCookieDecryptor, MacChromeCookieDecryptor, WindowsChromeCookieDecryptor, - parse_safari_cookies, - pbkdf2_sha1, _get_linux_desktop_environment, _LinuxDesktopEnvironment, + parse_safari_cookies, + pbkdf2_sha1, ) diff --git a/test/test_download.py b/test/test_download.py index 3c6b55d98..9a83bee2f 100755 --- a/test/test_download.py +++ b/test/test_download.py @@ -1,8 +1,12 @@ #!/usr/bin/env python3 # 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 ( @@ -16,24 +20,19 @@ from test.helper import ( try_rm, ) - -import hashlib -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 diff --git a/test/test_downloader_http.py b/test/test_downloader_http.py index c511909c7..c33308064 100644 --- a/test/test_downloader_http.py +++ b/test/test_downloader_http.py @@ -4,14 +4,16 @@ import os import re import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +import threading from test.helper import http_server_port, try_rm + from yt_dlp import YoutubeDL from yt_dlp.compat import compat_http_server from yt_dlp.downloader.http import HttpFD from yt_dlp.utils import encodeFilename -import threading TEST_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/test/test_execution.py b/test/test_execution.py index 623f08165..6a3e9944b 100644 --- a/test/test_execution.py +++ b/test/test_execution.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -import unittest - -import sys import os import subprocess +import sys +import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from yt_dlp.utils import encodeArgument diff --git a/test/test_http.py b/test/test_http.py index 2106220eb..029996ca9 100644 --- a/test/test_http.py +++ b/test/test_http.py @@ -3,13 +3,15 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +import ssl +import threading from test.helper import http_server_port + from yt_dlp import YoutubeDL from yt_dlp.compat import compat_http_server, compat_urllib_request -import ssl -import threading TEST_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/test/test_iqiyi_sdk_interpreter.py b/test/test_iqiyi_sdk_interpreter.py index 57a7ed3a8..4b82b7187 100644 --- a/test/test_iqiyi_sdk_interpreter.py +++ b/test/test_iqiyi_sdk_interpreter.py @@ -3,9 +3,11 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from test.helper import FakeYDL, is_download_test + from yt_dlp.extractor import IqiyiIE diff --git a/test/test_jsinterp.py b/test/test_jsinterp.py index 10a465cf9..872c58c8f 100644 --- a/test/test_jsinterp.py +++ b/test/test_jsinterp.py @@ -3,6 +3,7 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from yt_dlp.jsinterp import JSInterpreter diff --git a/test/test_netrc.py b/test/test_netrc.py index adc3a0ed1..f7a0b33d2 100644 --- a/test/test_netrc.py +++ b/test/test_netrc.py @@ -1,6 +1,7 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) diff --git a/test/test_overwrites.py b/test/test_overwrites.py index 8e0548db5..39741b65c 100644 --- a/test/test_overwrites.py +++ b/test/test_overwrites.py @@ -1,14 +1,14 @@ #!/usr/bin/env python3 import os -from os.path import join import subprocess import sys import unittest +from os.path import join + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from test.helper import is_download_test, try_rm - root_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) download_file = join(root_dir, 'test.webm') diff --git a/test/test_post_hooks.py b/test/test_post_hooks.py index 020203f2f..e84a08f29 100644 --- a/test/test_post_hooks.py +++ b/test/test_post_hooks.py @@ -2,9 +2,11 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from test.helper import get_params, try_rm, is_download_test +from test.helper import get_params, is_download_test, try_rm + import yt_dlp.YoutubeDL from yt_dlp.utils import DownloadError diff --git a/test/test_postprocessors.py b/test/test_postprocessors.py index e5893f7d2..9d8a4dcc5 100644 --- a/test/test_postprocessors.py +++ b/test/test_postprocessors.py @@ -13,7 +13,7 @@ from yt_dlp.postprocessor import ( FFmpegThumbnailsConvertorPP, MetadataFromFieldPP, MetadataParserPP, - ModifyChaptersPP + ModifyChaptersPP, ) diff --git a/test/test_socks.py b/test/test_socks.py index 02723b469..546f0d73d 100644 --- a/test/test_socks.py +++ b/test/test_socks.py @@ -3,20 +3,14 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import random import subprocess +from test.helper import FakeYDL, get_params, is_download_test -from test.helper import ( - FakeYDL, - get_params, - is_download_test, -) -from yt_dlp.compat import ( - compat_str, - compat_urllib_request, -) +from yt_dlp.compat import compat_str, compat_urllib_request @is_download_test diff --git a/test/test_subtitles.py b/test/test_subtitles.py index 0be1842da..362b67cef 100644 --- a/test/test_subtitles.py +++ b/test/test_subtitles.py @@ -3,29 +3,29 @@ import os import sys import unittest -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) -from test.helper import FakeYDL, md5, is_download_test +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +from test.helper import FakeYDL, is_download_test, md5 from yt_dlp.extractor import ( - YoutubeIE, - DailymotionIE, - TedTalkIE, - VimeoIE, - WallaIE, - CeskaTelevizeIE, - LyndaIE, NPOIE, + NRKTVIE, PBSIE, + CeskaTelevizeIE, ComedyCentralIE, - NRKTVIE, + DailymotionIE, + DemocracynowIE, + LyndaIE, RaiPlayIE, - VikiIE, - ThePlatformIE, - ThePlatformFeedIE, RTVEALaCartaIE, - DemocracynowIE, + TedTalkIE, + ThePlatformFeedIE, + ThePlatformIE, + VikiIE, + VimeoIE, + WallaIE, + YoutubeIE, ) diff --git a/test/test_update.py.disabled b/test/test_update.py.disabled index 5f0794ae2..389b8ffe5 100644 --- a/test/test_update.py.disabled +++ b/test/test_update.py.disabled @@ -3,10 +3,12 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import json + from yt_dlp.update import rsa_verify diff --git a/test/test_utils.py b/test/test_utils.py index e0c862807..7909dc61c 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -3,6 +3,7 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) @@ -12,75 +13,95 @@ import itertools import json import xml.etree.ElementTree +from yt_dlp.compat import ( + compat_chr, + compat_etree_fromstring, + compat_getenv, + compat_HTMLParseError, + compat_os_name, + compat_setenv, +) from yt_dlp.utils import ( + Config, + DateRange, + ExtractorError, + InAdvancePagedList, + LazyList, + OnDemandPagedList, age_restricted, args_to_str, - encode_base_n, + base_url, caesar, clean_html, clean_podcast_url, - Config, + cli_bool_option, + cli_option, + cli_valueless_option, date_from_str, datetime_from_str, - DateRange, detect_exe_version, determine_ext, + dfxp2srt, dict_get, + encode_base_n, encode_compat_str, encodeFilename, escape_rfc3986, escape_url, + expand_path, extract_attributes, - ExtractorError, find_xpath_attr, fix_xml_ampersands, - format_bytes, float_or_none, - get_element_by_class, + format_bytes, get_element_by_attribute, - get_elements_by_class, - get_elements_by_attribute, - get_element_html_by_class, + get_element_by_class, get_element_html_by_attribute, - get_elements_html_by_class, + get_element_html_by_class, + get_element_text_and_html_by_tag, + get_elements_by_attribute, + get_elements_by_class, get_elements_html_by_attribute, + get_elements_html_by_class, get_elements_text_and_html_by_attribute, - get_element_text_and_html_by_tag, - InAdvancePagedList, int_or_none, intlist_to_bytes, + iri_to_uri, is_html, js_to_json, limit_length, locked_file, + lowercase_escape, + match_str, merge_dicts, mimetype2ext, month_by_name, multipart_encode, ohdave_rsa_encrypt, - OnDemandPagedList, orderedSet, parse_age_limit, + parse_bitrate, + parse_codecs, + parse_count, + parse_dfxp_time_expr, parse_duration, parse_filesize, - parse_count, parse_iso8601, - parse_resolution, - parse_bitrate, parse_qs, + parse_resolution, pkcs1pad, + prepend_extension, read_batch_urls, + remove_end, + remove_quotes, + remove_start, + render_table, + replace_extension, + rot47, sanitize_filename, sanitize_path, sanitize_url, sanitized_Request, - expand_path, - prepend_extension, - replace_extension, - remove_start, - remove_end, - remove_quotes, - rot47, shell_quote, smuggle_url, str_to_int, @@ -92,38 +113,18 @@ from yt_dlp.utils import ( unified_strdate, unified_timestamp, unsmuggle_url, + update_url_query, uppercase_escape, - lowercase_escape, url_basename, url_or_none, - base_url, - urljoin, urlencode_postdata, + urljoin, urshift, - update_url_query, version_tuple, - xpath_with_ns, + xpath_attr, xpath_element, xpath_text, - xpath_attr, - render_table, - match_str, - parse_dfxp_time_expr, - dfxp2srt, - cli_option, - cli_valueless_option, - cli_bool_option, - parse_codecs, - iri_to_uri, - LazyList, -) -from yt_dlp.compat import ( - compat_chr, - compat_etree_fromstring, - compat_getenv, - compat_HTMLParseError, - compat_os_name, - compat_setenv, + xpath_with_ns, ) diff --git a/test/test_verbose_output.py b/test/test_verbose_output.py index 17aeafbc0..1213a9726 100644 --- a/test/test_verbose_output.py +++ b/test/test_verbose_output.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 -import unittest - -import sys import os import subprocess +import sys +import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) rootDir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/test/test_write_annotations.py.disabled b/test/test_write_annotations.py.disabled index 4173fd09d..bf13efe2c 100644 --- a/test/test_write_annotations.py.disabled +++ b/test/test_write_annotations.py.disabled @@ -3,17 +3,15 @@ import os import sys import unittest -sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - -from test.helper import get_params, try_rm, is_download_test +sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) import io - import xml.etree.ElementTree +from test.helper import get_params, is_download_test, try_rm -import yt_dlp.YoutubeDL import yt_dlp.extractor +import yt_dlp.YoutubeDL class YoutubeDL(yt_dlp.YoutubeDL): diff --git a/test/test_youtube_lists.py b/test/test_youtube_lists.py index 8691abb67..66611e236 100644 --- a/test/test_youtube_lists.py +++ b/test/test_youtube_lists.py @@ -3,14 +3,12 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from test.helper import FakeYDL, is_download_test -from yt_dlp.extractor import ( - YoutubeIE, - YoutubeTabIE, -) +from yt_dlp.extractor import YoutubeIE, YoutubeTabIE @is_download_test diff --git a/test/test_youtube_misc.py b/test/test_youtube_misc.py index 70d6d9949..36f8be689 100644 --- a/test/test_youtube_misc.py +++ b/test/test_youtube_misc.py @@ -3,6 +3,7 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) diff --git a/test/test_youtube_signature.py b/test/test_youtube_signature.py index d751d5396..ca23c910d 100644 --- a/test/test_youtube_signature.py +++ b/test/test_youtube_signature.py @@ -3,16 +3,17 @@ import os import sys import unittest + sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) 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 _SIG_TESTS = [ ( |