-
Notifications
You must be signed in to change notification settings - Fork 10.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Test] Improve download test #29944
Open
dirkf
wants to merge
15
commits into
ytdl-org:master
Choose a base branch
from
dirkf:df-testdl-patch
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
[Test] Improve download test #29944
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dirkf
force-pushed
the
df-testdl-patch
branch
from
September 11, 2021 12:14
1e3e826
to
aeb9db4
Compare
External downloaders may not support limiting the download to a specified size
Header-related params are parsed into `std_headers` rather than the `params` dict, but this wasn't respected for test cases.
11 tasks
dirkf
force-pushed
the
df-testdl-patch
branch
from
October 11, 2021 19:15
aeb9db4
to
47eba6f
Compare
So TestDownload.test_XXX_all runs all the download test cases for the XXX extractor.
dirkf
force-pushed
the
df-testdl-patch
branch
from
October 11, 2021 19:39
47eba6f
to
5ab2dbe
Compare
7 tasks
Grub4K
reviewed
Oct 18, 2022
Note to self:
|
Co-authored-by: Simon Sawicki <[email protected]>
dirkf
commented
Jan 28, 2023
dirkf
commented
Feb 21, 2024
dirkf
commented
Feb 21, 2024
dirkf
commented
Feb 21, 2024
dirkf
commented
Feb 21, 2024
* make fake `report_warning()` method signatures correct (per 640d39f) * support single warning to expect as well as sequence * don't colour text to be matched * use `expected_warnings()` function throughout
dirkf
commented
May 23, 2024
Open
10 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Boilerplate: own code/improvement
Please follow the guide belowBefore submitting a pull request make sure you have:
In order to be accepted and merged into youtube-dl each piece of code must be in public domain or released under Unlicense. Check one of the following options:
What is the purpose of your pull request?
Description of your pull request and other information
This PR makes two small and one larger improvement to
test/test_download.py
, in 3 separate commits.Calculating the file hash
External downloaders may not support limiting the download exactly to a specified size. When running a test download, only a short initial portion of the file is supposed to be downloaded, and the hash is calculated from that portion. If the portion is longer than requested the hash will be incorrect. The PR explicitly uses the requested length, if specified, when calculating the file hash, so that the same value should be calculated regardless of downloader.
Header-related params in test cases
Header-related params (here:
--user-agent
,--referer
,--add-header
) are parsed intostd_headers
rather than theparams
dict in the main yt-dl program. In download tests, only params that are set into theparams
dict were supported, and header-related params in test cases were ignored. This PR changes the params processing for test downloads to match what happens in the main program.As an example, the change makes it possible to specify a test case with a specific UA, such as this for an Invidious site fronted by Cloudflare
Add TestSuite test_..._all with all downloads for each extractor
When testing downloads for an extractor XXX, a set of test cases is created but it's not obvious which item in the extractor's
_TESTS
list corresponds to whichTestDownload.test_XXX...
test case. If there are many test cases one might fail to run some of the later tests, or run past the highest numbered case.To facilitate running the download tests for an extractor in the same way that they run in the CI servers, the PR adds a further download test case with name suffix
_all
for each extractor class that has test case(s). The new test case is aunittest.TestSuite
that runs all the other download tests for that extractor. Counts of the possible test outcomes (error, failure, etc) are printed.Thus to test
YoutubeIE
:Supersedes, closes #27461.