Skip to content
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

playlist tests require working DNS #317

Open
benaryorg opened this issue Nov 7, 2024 · 1 comment
Open

playlist tests require working DNS #317

benaryorg opened this issue Nov 7, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@benaryorg
Copy link
Contributor

benaryorg commented Nov 7, 2024


Describe the bug
Two playlist tests are currently failing in the nixpkgs tests (ignore the cipher tests, I opened a second PR to fix those) as they require DNS to resolve which fails in a sandboxed environment (such as the nix build environment).
Since all other tests pass just fine and there's mocking in place I figure that these tests specifically are doing some additional requests which somehow bypass the mocking, which would mean that a) tests suites may currently cause requests against the live YouTube API which may have adverse effects on people running the test suite locally (like being treated as bots by YouTube and being unable to watch without an account like many others) and b) the tests may not be pure and fail depending on upstream changes which runs counter to the intention of those tests.


code that was used that resulted in the bug

The logs above contain a full trace, however it seems that the pagination bypasses the mock:

for page in self._paginate(self.html):
for video in page:
yield self._video_url(video)

And is triggered in these two tests:

FAILED tests/contrib/test_playlist.py::test_playlist_failed_pagination - urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name ...
FAILED tests/contrib/test_playlist.py::test_playlist_pagination - urllib.error.URLError: <urlopen error [Errno -3] Temporary failure in name ...

Expected behavior
Tests should pass even when DNS resolution is not available.
Tests should not make requests to the YouTube API.


Desktop (please complete the following information):

  • OS: NixOS unstable
  • Python Version: 3.11.10
  • Pytubefix Version: main

Additional context
I'd proceed to disable those tests downstream for now, and it's not terribly important, so this is more of a nice to have, and if those tests are made to work without DNS I'd be happy to enable them again.

@benaryorg benaryorg added the bug Something isn't working label Nov 7, 2024
@benaryorg
Copy link
Contributor Author

Oh my, it seems I've entirely missed that a large chunk of tests have already been disabled as they require network access. My bad.

It'd be cool if they could run without network access, but given that there are already many disabled tests I see no urgency whatsoever.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: enhancement
Development

No branches or pull requests

1 participant