repo_id stringclasses 409
values | prefix large_stringlengths 34 36.3k | target large_stringlengths 1 498 | assertion_type stringclasses 31
values | difficulty stringclasses 8
values | test_file stringlengths 10 121 | test_function stringlengths 1 104 | test_class stringlengths 0 51 | lineno int32 2 11.3k | commit_idx int32 |
|---|---|---|---|---|---|---|---|---|---|
JuanBindez/pytubefix | import os
import random
import pytest
from datetime import datetime
from unittest import mock
from unittest.mock import MagicMock, Mock
from urllib.error import HTTPError
from pytubefix import request, Stream
def test_length(cipher_signature):
assert cipher_signature.length == | 337 | assert | numeric_literal | tests/test_streams.py | test_length | 118 | null | |
JuanBindez/pytubefix | import datetime
from unittest import mock
from pytubefix import Playlist
@mock.patch("pytubefix.request.get")
def test_trimmed(request_get, playlist_html):
url = "https://www.fakeurl.com/playlist?list=whatever"
request_get.return_value = playlist_html
playlist = Playlist(url)
trimmed = list(playlist.t... | 1 | assert | numeric_literal | tests/contrib/test_playlist.py | test_trimmed | 162 | null | |
JuanBindez/pytubefix | import pytest
from unittest import mock
import pytubefix.exceptions as exceptions
from pytubefix import YouTube
from pytubefix.helpers import strip_color_codes
def test_region_locked_error():
# Ensure this can be caught as generic VideoUnavailable exception
with pytest.raises(exceptions.VideoUnavailable):
... | 'hZpzr8TbF08 is not available in your region' | assert | string_literal | tests/test_exceptions.py | test_region_locked_error | 65 | null | |
JuanBindez/pytubefix | from datetime import datetime
import pytest
import re
from pytubefix import extract
from pytubefix.exceptions import RegexMatchError
def test_publish_date(cipher_signature):
expected = datetime(2019, 12, 5)
assert cipher_signature.publish_date == | expected | assert | variable | tests/test_extract.py | test_publish_date | 64 | null | |
JuanBindez/pytubefix | from unittest import mock
from pytubefix import Channel
@mock.patch('pytubefix.request.get')
def test_videos_html(request_get, channel_videos_html):
request_get.return_value = channel_videos_html
c = Channel('https://www.youtube.com/c/ProgrammingKnowledge')
assert c.html == | channel_videos_html | assert | variable | tests/contrib/test_channel.py | test_videos_html | 76 | null | |
JuanBindez/pytubefix | from unittest import mock
from pytubefix import Channel
@mock.patch('pytubefix.request.get')
def test_channel_name(request_get, channel_videos_html):
request_get.return_value = channel_videos_html
c = Channel('https://www.youtube.com/c/ProgrammingKnowledge/videos')
assert c.channel_name == | 'ProgrammingKnowledge' | assert | string_literal | tests/contrib/test_channel.py | test_channel_name | 34 | null | |
JuanBindez/pytubefix | from unittest import mock
from pytubefix import Channel
@mock.patch('pytubefix.request.get')
def test_init_with_url(request_get, channel_videos_html):
request_get.return_value = channel_videos_html
c = Channel('https://www.youtube.com/c/ProgrammingKnowledge/videos')
assert c.channel_url == 'https://www.yo... | f'{c.channel_url}/about' | assert | string_literal | tests/contrib/test_channel.py | test_init_with_url | 15 | null | |
JuanBindez/pytubefix | import argparse
import logging
import os
from unittest import mock
from unittest.mock import MagicMock, patch
import pytest
from pytubefix import Caption, CaptionQuery, cli, StreamQuery
from pytubefix.exceptions import PytubeFixError
from urllib.error import HTTPError
parse_args = cli._parse_args
@mock.patch("pytub... | SystemExit) | pytest.raises | variable | tests/test_cli.py | test_download_when_itag_not_found | 37 | null | |
JuanBindez/pytubefix | import datetime
from unittest import mock
from pytubefix import Playlist
@mock.patch("pytubefix.request.get")
@mock.patch("pytubefix.request.post")
def test_playlist_failed_pagination(request_post, request_get, playlist_long_html):
url = "https://www.fakeurl.com/playlist?list=whatever"
request_get.side_effect... | 100 | assert | numeric_literal | tests/contrib/test_playlist.py | test_playlist_failed_pagination | 177 | null | |
JuanBindez/pytubefix | import pytest
from pytubefix import cipher
from pytubefix.exceptions import RegexMatchError
def test_get_throttling_function_name(base_js):
base_js_code_fragments = [
# Values expected as of 2022/02/04:
{
'raw_var': r'var Apa=[hha]',
'raw_code': r'a.url="";a.C&&(b=a.get("n"... | code_fragment['nfunc_name'] | assert | complex_expr | tests/test_cipher.py | test_get_throttling_function_name | 42 | null | |
JuanBindez/pytubefix | import os
import random
import pytest
from datetime import datetime
from unittest import mock
from unittest.mock import MagicMock, Mock
from urllib.error import HTTPError
from pytubefix import request, Stream
def test_default_filename(cipher_signature):
expected = "YouTube Rewind 2019 For the Record YouTubeRewin... | expected | assert | variable | tests/test_streams.py | test_default_filename | 57 | null | |
JuanBindez/pytubefix | import datetime
from unittest import mock
from pytubefix import Playlist
@mock.patch("pytubefix.request.get")
@mock.patch("pytubefix.contrib.playlist.install_proxy", return_value=None)
def test_proxy(install_proxy, request_get):
url = "https://www.fakeurl.com/playlist?list=whatever"
request_get.return_value =... | {"http": "things"}) | assert_* | collection | tests/contrib/test_playlist.py | test_proxy | 149 | null | |
JuanBindez/pytubefix | from datetime import datetime
import pytest
import re
from pytubefix import extract
from pytubefix.exceptions import RegexMatchError
def test_info_url(age_restricted):
video_info_url = extract.video_info_url_age_restricted(
video_id="QRS8MkLhQmM", embed_html=age_restricted["embed_html"],
)
assert ... | video_info_url | assert | variable | tests/test_extract.py | test_info_url | 21 | null | |
JuanBindez/pytubefix | import json
import pytest
from pytubefix.exceptions import HTMLParseError
from pytubefix.parser import parse_for_object
def test_parse_simple_empty_object():
result = parse_for_object('test = {}', r'test\s*=\s*')
assert result == | {} | assert | collection | tests/test_parser.py | test_parse_simple_empty_object | 15 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
def test_caption_query_sequence():
caption1 = Caption(
{"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
)
... | KeyError) | pytest.raises | variable | tests/test_captions.py | test_caption_query_sequence | 27 | null | |
JuanBindez/pytubefix | from unittest import mock
import pytest
import pytubefix
from pytubefix import YouTube
from pytubefix.exceptions import RegexMatchError
def test_video_keywords(cipher_signature):
expected = [
'Rewind', 'Rewind 2019',
'youtube rewind 2019', '#YouTubeRewind',
'MrBeast', 'PewDiePie', 'James ... | expected | assert | variable | tests/test_main.py | test_video_keywords | 45 | null | |
JuanBindez/pytubefix | from datetime import datetime
import pytest
import re
from pytubefix import extract
from pytubefix.exceptions import RegexMatchError
def test_mime_type_codec_with_no_match_should_error():
with pytest.raises( | RegexMatchError) | pytest.raises | variable | tests/test_extract.py | test_mime_type_codec_with_no_match_should_error | 81 | null | |
JuanBindez/pytubefix | import json
import pytest
from pytubefix.exceptions import HTMLParseError
from pytubefix.parser import parse_for_object
def test_invalid_start():
with pytest.raises( | HTMLParseError) | pytest.raises | variable | tests/test_parser.py | test_invalid_start | 9 | null | |
JuanBindez/pytubefix | import argparse
import logging
import os
from unittest import mock
from unittest.mock import MagicMock, patch
import pytest
from pytubefix import Caption, CaptionQuery, cli, StreamQuery
from pytubefix.exceptions import PytubeFixError
from urllib.error import HTTPError
parse_args = cli._parse_args
def test_parse_arg... | False | assert | bool_literal | tests/test_cli.py | test_parse_args_falsey | 146 | null | |
JuanBindez/pytubefix | import pytest
def test_get_highest_resolution(cipher_signature):
assert cipher_signature.streams.get_highest_resolution().itag == | 22 | assert | numeric_literal | tests/test_query.py | test_get_highest_resolution | 164 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
def test_float_to_srt_time_format():
caption1 = Caption(
{"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
... | "00:00:03,890" | assert | string_literal | tests/test_captions.py | test_float_to_srt_time_format | 13 | null | |
JuanBindez/pytubefix | from datetime import datetime
import pytest
import re
from pytubefix import extract
from pytubefix.exceptions import RegexMatchError
def test_mime_type_codec():
mime_type, mime_subtype = extract.mime_type_codec(
'audio/webm; codecs="opus"'
)
assert mime_type == "audio/webm"
assert mime_subtyp... | ["opus"] | assert | collection | tests/test_extract.py | test_mime_type_codec | 77 | null | |
JuanBindez/pytubefix | import datetime
from unittest import mock
from pytubefix import Playlist
@mock.patch("pytubefix.request.get")
def test_init_with_playlist_url(request_get):
request_get.return_value = ""
url = (
"https://www.youtube.com/playlist?list=PLS1QulWo1RIaJECMeUT4LFwJ"
"-ghgoSH6n"
)
playlist = P... | url | assert | variable | tests/contrib/test_playlist.py | test_init_with_playlist_url | 30 | null | |
JuanBindez/pytubefix | import pytest
def test_get_last(cipher_signature):
"""Ensure :meth:`~pytubefix.StreamQuery.last` returns the expected
:class:`Stream <Stream>`.
"""
assert cipher_signature.streams[-1].itag == | 251 | assert | numeric_literal | tests/test_query.py | test_get_last | 46 | null | |
JuanBindez/pytubefix | from datetime import datetime
import pytest
import re
from pytubefix import extract
from pytubefix.exceptions import RegexMatchError
def test_mime_type_codec():
mime_type, mime_subtype = extract.mime_type_codec(
'audio/webm; codecs="opus"'
)
assert mime_type == | "audio/webm" | assert | string_literal | tests/test_extract.py | test_mime_type_codec | 76 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
@mock.patch("pytubefix.captions.request")
def test_generate_srt_captions(request):
clean_text = lambda x: x.replace(' ', '').replace('\n', '')
xml_dat... | clean_text(expected_output) | assert | func_call | tests/test_captions.py | test_generate_srt_captions | 213 | null | |
JuanBindez/pytubefix | import pytest
def test_order_by_non_numerical(cipher_signature):
mime_types = [
s.mime_type
for s in cipher_signature.streams.filter(res="360p")
.order_by("mime_type")
.desc()
]
assert mime_types == | ["video/webm", "video/mp4", "video/mp4", "video/mp4"] | assert | collection | tests/test_query.py | test_order_by_non_numerical | 99 | null | |
JuanBindez/pytubefix | import gzip
import io
import json
import os
import pytest
from unittest import mock
from pytubefix import helpers
from pytubefix.exceptions import RegexMatchError
from pytubefix.helpers import cache, create_mock_html_json, deprecated, setup_logger
from pytubefix.helpers import target_directory, uniqueify
def test_cac... | 2 | assert | numeric_literal | tests/test_helpers.py | test_cache | 57 | null | |
JuanBindez/pytubefix | import pytest
def test_get_audio_only(cipher_signature):
assert cipher_signature.streams.get_audio_only().itag == | 140 | assert | numeric_literal | tests/test_query.py | test_get_audio_only | 174 | null | |
JuanBindez/pytubefix | import gzip
import io
import json
import os
import pytest
from unittest import mock
from pytubefix import helpers
from pytubefix.exceptions import RegexMatchError
from pytubefix.helpers import cache, create_mock_html_json, deprecated, setup_logger
from pytubefix.helpers import target_directory, uniqueify
@mock.patch(... | os.path.join("/cwd", "test") | assert | func_call | tests/test_helpers.py | test_target_directory_with_relative_path | 64 | null | |
JuanBindez/pytubefix | import argparse
import logging
import os
from unittest import mock
from unittest.mock import MagicMock, patch
import pytest
from pytubefix import Caption, CaptionQuery, cli, StreamQuery
from pytubefix.exceptions import PytubeFixError
from urllib.error import HTTPError
parse_args = cli._parse_args
@mock.patch("pytub... | args) | assert_* | variable | tests/test_cli.py | test_download_with_playlist | 273 | null | |
JuanBindez/pytubefix | import argparse
import logging
import os
from unittest import mock
from unittest.mock import MagicMock, patch
import pytest
from pytubefix import Caption, CaptionQuery, cli, StreamQuery
from pytubefix.exceptions import PytubeFixError
from urllib.error import HTTPError
parse_args = cli._parse_args
@mock.patch("pytub... | 10) | assert_* | numeric_literal | tests/test_cli.py | test_on_progress | 139 | null | |
JuanBindez/pytubefix | from pytubefix import itags
def test_get_format_profile():
profile = itags.get_format_profile(22)
assert profile["resolution"] == | "720p" | assert | string_literal | tests/test_itags.py | test_get_format_profile | 6 | null | |
JuanBindez/pytubefix | from pytubefix import extract
def test_extract_metadata_empty():
ytmd = extract.metadata({})
assert ytmd._raw_metadata == | [] | assert | collection | tests/test_metadata.py | test_extract_metadata_empty | 7 | null | |
JuanBindez/pytubefix | import datetime
from unittest import mock
from pytubefix import Playlist
@mock.patch("pytubefix.request.get")
def test_last_updated(request_get, playlist_long_html):
expected = datetime.date(2023, 4, 18)
request_get.return_value = playlist_long_html
playlist = Playlist(
"https://www.youtube.com/pl... | expected | assert | variable | tests/contrib/test_playlist.py | test_last_updated | 55 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
@mock.patch("pytubefix.captions.Caption.xml_captions")
def test_download_xml_and_trim_extension(xml):
open_mock = mock_open()
with patch("builtins.open"... | "title (en).xml" | assert | string_literal | tests/test_captions.py | test_download_xml_and_trim_extension | 127 | null | |
JuanBindez/pytubefix | from pytubefix import itags
def test_get_format_profile_non_existant():
profile = itags.get_format_profile(2239)
assert profile["resolution"] is | None | assert | none_literal | tests/test_itags.py | test_get_format_profile_non_existant | 11 | null | |
JuanBindez/pytubefix | from pytubefix import extract
def test_metadata_from_initial_data(stream_dict):
initial_data = extract.initial_data(stream_dict)
ytmd = extract.metadata(initial_data)
assert len(ytmd.raw_metadata) > 0
assert 'contents' in ytmd.raw_metadata[0]
assert len(ytmd.metadata) > 0
assert 'Song' in | ytmd.metadata[0] | assert | complex_expr | tests/test_metadata.py | test_metadata_from_initial_data | 16 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
def test_repr():
caption = Caption(
{"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
)
assert str(cap... | '<Caption lang="name1" code="en">' | assert | string_literal | tests/test_captions.py | test_repr | 136 | null | |
JuanBindez/pytubefix | import datetime
from unittest import mock
from pytubefix import Playlist
@mock.patch("pytubefix.request.get")
def test_playlist_length(request_get, playlist_long_html):
url = 'https://www.example.com/playlist?list=whatever'
request_get.return_value = playlist_long_html
p = Playlist(url)
assert p.leng... | 233 | assert | numeric_literal | tests/contrib/test_playlist.py | test_playlist_length | 268 | null | |
JuanBindez/pytubefix | import gzip
import io
import json
import os
import pytest
from unittest import mock
from pytubefix import helpers
from pytubefix.exceptions import RegexMatchError
from pytubefix.helpers import cache, create_mock_html_json, deprecated, setup_logger
from pytubefix.helpers import target_directory, uniqueify
@mock.patch(... | "Call to deprecated function deprecated_function (oh no).") | assert_* | string_literal | tests/test_helpers.py | test_deprecated | 36 | null | |
JuanBindez/pytubefix | from unittest import mock
from pytubefix import Channel
@mock.patch('pytubefix.request.get')
def test_init_with_url(request_get, channel_videos_html):
request_get.return_value = channel_videos_html
c = Channel('https://www.youtube.com/c/ProgrammingKnowledge/videos')
assert c.channel_url == 'https://www.yo... | f'{c.channel_url}/playlists' | assert | string_literal | tests/contrib/test_channel.py | test_init_with_url | 12 | null | |
JuanBindez/pytubefix | import socket
import os
import pytest
from unittest import mock
from urllib.error import URLError
from pytubefix import request
from pytubefix.exceptions import MaxRetriesExceeded
@mock.patch("pytubefix.request.urlopen")
def test_streaming(mock_urlopen):
# Given
fake_stream_binary = [
os.urandom(8 * 1... | 4 + 1 | assert | complex_expr | tests/test_request.py | test_streaming | 32 | null | |
JuanBindez/pytubefix | import argparse
import logging
import os
from unittest import mock
from unittest.mock import MagicMock, patch
import pytest
from pytubefix import Caption, CaptionQuery, cli, StreamQuery
from pytubefix.exceptions import PytubeFixError
from urllib.error import HTTPError
parse_args = cli._parse_args
def test_parse_arg... | None | assert | none_literal | tests/test_cli.py | test_parse_args_falsey | 147 | null | |
JuanBindez/pytubefix | import socket
import os
import pytest
from unittest import mock
from urllib.error import URLError
from pytubefix import request
from pytubefix.exceptions import MaxRetriesExceeded
@mock.patch("pytubefix.request.urlopen")
def test_get(mock_urlopen):
response = mock.Mock()
response.read.return_value = "<html></... | "<html></html>" | assert | string_literal | tests/test_request.py | test_get | 57 | null | |
JuanBindez/pytubefix | from unittest import mock
from pytubefix import Channel
@mock.patch('pytubefix.request.get')
def test_channel_uri(request_get, channel_videos_html):
request_get.return_value = channel_videos_html
c = Channel('https://www.youtube.com/c/ProgrammingKnowledge/videos')
assert c.channel_uri == | '/c/ProgrammingKnowledge' | assert | string_literal | tests/contrib/test_channel.py | test_channel_uri | 23 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
def test_caption_query_sequence():
caption1 = Caption(
{"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
)
... | caption1 | assert | variable | tests/test_captions.py | test_caption_query_sequence | 25 | null | |
JuanBindez/pytubefix | import json
import pytest
from pytubefix.exceptions import HTMLParseError
from pytubefix.parser import parse_for_object
def test_parse_object_requiring_ast():
invalid_json = '{"foo": "bar",}'
test_html = f'test = {invalid_json}'
with pytest.raises( | json.decoder.JSONDecodeError) | pytest.raises | complex_expr | tests/test_parser.py | test_parse_object_requiring_ast | 53 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
def test_caption_query_sequence():
caption1 = Caption(
{"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
)
... | 2 | assert | numeric_literal | tests/test_captions.py | test_caption_query_sequence | 24 | null | |
JuanBindez/pytubefix | import os
import random
import pytest
from datetime import datetime
from unittest import mock
from unittest.mock import MagicMock, Mock
from urllib.error import HTTPError
from pytubefix import request, Stream
def test_author(cipher_signature):
assert cipher_signature.author == | 'YouTube' | assert | string_literal | tests/test_streams.py | test_author | 262 | null | |
JuanBindez/pytubefix | import gzip
import io
import json
import os
import pytest
from unittest import mock
from pytubefix import helpers
from pytubefix.exceptions import RegexMatchError
from pytubefix.helpers import cache, create_mock_html_json, deprecated, setup_logger
from pytubefix.helpers import target_directory, uniqueify
def test_reg... | "a" | assert | string_literal | tests/test_helpers.py | test_regex_search | 20 | null | |
JuanBindez/pytubefix | import pytest
from unittest import mock
import pytubefix.exceptions as exceptions
from pytubefix import YouTube
from pytubefix.helpers import strip_color_codes
def test_live_stream_error():
# Ensure this can be caught as generic VideoUnavailable exception
with pytest.raises(exceptions.VideoUnavailable):
... | 'YLnZklYFe7E' | assert | string_literal | tests/test_exceptions.py | test_live_stream_error | 31 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
@mock.patch("pytubefix.captions.Caption.generate_srt_captions")
def test_download_with_prefix(srt):
open_mock = mock_open()
with patch("builtins.open", ... | "1 title (en).srt" | assert | string_literal | tests/test_captions.py | test_download_with_prefix | 88 | null | |
JuanBindez/pytubefix | import pytest
from unittest import mock
import pytubefix.exceptions as exceptions
from pytubefix import YouTube
from pytubefix.helpers import strip_color_codes
def test_recording_unavailable_error():
# Ensure this can be caught as generic VideoUnavailable exception
with pytest.raises(exceptions.VideoUnavailab... | '5YceQ8YqYMc does not have a live stream recording available' | assert | string_literal | tests/test_exceptions.py | test_recording_unavailable_error | 43 | null | |
JuanBindez/pytubefix | import pytest
from unittest import mock
import pytubefix.exceptions as exceptions
from pytubefix import YouTube
from pytubefix.helpers import strip_color_codes
def test_recording_unavailable_error():
# Ensure this can be caught as generic VideoUnavailable exception
with pytest.raises(exceptions.VideoUnavailab... | '5YceQ8YqYMc' | assert | string_literal | tests/test_exceptions.py | test_recording_unavailable_error | 42 | null | |
JuanBindez/pytubefix | import gzip
import io
import json
import os
import pytest
from unittest import mock
from pytubefix import helpers
from pytubefix.exceptions import RegexMatchError
from pytubefix.helpers import cache, create_mock_html_json, deprecated, setup_logger
from pytubefix.helpers import target_directory, uniqueify
def test_saf... | "abc1245" | assert | string_literal | tests/test_helpers.py | test_safe_filename | 25 | null | |
JuanBindez/pytubefix | from datetime import datetime
import pytest
import re
from pytubefix import extract
from pytubefix.exceptions import RegexMatchError
def test_extract_video_id():
url = "https://www.youtube.com/watch?v=2lAe1cqCOXo"
video_id = extract.video_id(url)
assert video_id == | "2lAe1cqCOXo" | assert | string_literal | tests/test_extract.py | test_extract_video_id | 13 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
def test_caption_query_sequence():
caption1 = Caption(
{"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
)
... | None | assert | none_literal | tests/test_captions.py | test_caption_query_sequence | 28 | null | |
JuanBindez/pytubefix | import pytest
def test_otf(cipher_signature):
non_otf = cipher_signature.streams.otf()
assert len(non_otf) == 26
otf = cipher_signature.streams.otf(True)
assert len(otf) == | 0 | assert | numeric_literal | tests/test_query.py | test_otf | 191 | null | |
JuanBindez/pytubefix | import gzip
import io
import json
import os
import pytest
from unittest import mock
from pytubefix import helpers
from pytubefix.exceptions import RegexMatchError
from pytubefix.helpers import cache, create_mock_html_json, deprecated, setup_logger
from pytubefix.helpers import target_directory, uniqueify
def test_uni... | expected | assert | variable | tests/test_helpers.py | test_uniqueify | 166 | null | |
JuanBindez/pytubefix | import socket
import os
import pytest
from unittest import mock
from urllib.error import URLError
from pytubefix import request
from pytubefix.exceptions import MaxRetriesExceeded
def test_get_non_http():
with pytest.raises( | ValueError) | pytest.raises | variable | tests/test_request.py | test_get_non_http | 61 | null | |
JuanBindez/pytubefix | from unittest import mock
import pytest
import pytubefix
from pytubefix import YouTube
from pytubefix.exceptions import RegexMatchError
def test_channel_url(cipher_signature):
assert cipher_signature.channel_url == | 'https://www.youtube.com/channel/UCBR8-60-B28hp2BmDPdntcQ' | assert | string_literal | tests/test_main.py | test_channel_url | 60 | null | |
JuanBindez/pytubefix | import os
import random
import pytest
from datetime import datetime
from unittest import mock
from unittest.mock import MagicMock, Mock
from urllib.error import HTTPError
from pytubefix import request, Stream
def test_views(cipher_signature):
assert cipher_signature.views >= | 108531745 | assert | numeric_literal | tests/test_streams.py | test_views | 122 | null | |
JuanBindez/pytubefix | import gzip
import io
import json
import os
import pytest
from unittest import mock
from pytubefix import helpers
from pytubefix.exceptions import RegexMatchError
from pytubefix.helpers import cache, create_mock_html_json, deprecated, setup_logger
from pytubefix.helpers import target_directory, uniqueify
@mock.patch(... | full_content[10:] | assert | complex_expr | tests/test_helpers.py | test_create_mock_html_json | 159 | null | |
JuanBindez/pytubefix | import argparse
import logging
import os
from unittest import mock
from unittest.mock import MagicMock, patch
import pytest
from pytubefix import Caption, CaptionQuery, cli, StreamQuery
from pytubefix.exceptions import PytubeFixError
from urllib.error import HTTPError
parse_args = cli._parse_args
@mock.patch("pytub... | stream) | assert_* | variable | tests/test_cli.py | test_download_by_resolution | 315 | null | |
JuanBindez/pytubefix | import pytest
from pytubefix import cipher
from pytubefix.exceptions import RegexMatchError
def test_get_initial_function_name_with_no_match_should_error():
with pytest.raises( | RegexMatchError) | pytest.raises | variable | tests/test_cipher.py | test_get_initial_function_name_with_no_match_should_error | 8 | null | |
JuanBindez/pytubefix | from unittest import mock
import pytest
import pytubefix
from pytubefix import YouTube
from pytubefix.exceptions import RegexMatchError
def test_js_caching(cipher_signature):
assert pytubefix.__js__ is not | None | assert | none_literal | tests/test_main.py | test_js_caching | 49 | null | |
JuanBindez/pytubefix | import pytest
from unittest import mock
import pytubefix.exceptions as exceptions
from pytubefix import YouTube
from pytubefix.helpers import strip_color_codes
def test_live_stream_error():
# Ensure this can be caught as generic VideoUnavailable exception
with pytest.raises( | exceptions.VideoUnavailable) | pytest.raises | complex_expr | tests/test_exceptions.py | test_live_stream_error | 26 | null | |
JuanBindez/pytubefix | from unittest import mock
import pytest
import pytubefix
from pytubefix import YouTube
from pytubefix.exceptions import RegexMatchError
def test_js_caching(cipher_signature):
assert pytubefix.__js__ is not None
assert pytubefix.__js_url__ is not None
assert cipher_signature.js == | pytubefix.__js__ | assert | complex_expr | tests/test_main.py | test_js_caching | 51 | null | |
JuanBindez/pytubefix | import datetime
from unittest import mock
from pytubefix import Playlist
@mock.patch("pytubefix.request.get")
def test_sequence(request_get, playlist_html):
url = "https://www.fakeurl.com/playlist?list=whatever"
request_get.return_value = playlist_html
playlist = Playlist(url)
assert playlist[0] == "h... | 12 | assert | numeric_literal | tests/contrib/test_playlist.py | test_sequence | 117 | null | |
JuanBindez/pytubefix | import pytest
from unittest import mock
import pytubefix.exceptions as exceptions
from pytubefix import YouTube
from pytubefix.helpers import strip_color_codes
def test_video_unavailable():
try:
raise exceptions.VideoUnavailable(video_id="YLnZklYFe7E")
except exceptions.VideoUnavailable as e:
... | "YLnZklYFe7E" | assert | string_literal | tests/test_exceptions.py | test_video_unavailable | 13 | null | |
JuanBindez/pytubefix | from unittest import mock
import pytest
import pytubefix
from pytubefix import YouTube
from pytubefix.exceptions import RegexMatchError
def test_js_caching(cipher_signature):
assert pytubefix.__js__ is not None
assert pytubefix.__js_url__ is not None
assert cipher_signature.js == pytubefix.__js__
as... | pytubefix.__js_url__ | assert | complex_expr | tests/test_main.py | test_js_caching | 52 | null | |
JuanBindez/pytubefix | import argparse
import logging
import os
from unittest import mock
from unittest.mock import MagicMock, patch
import pytest
from pytubefix import Caption, CaptionQuery, cli, StreamQuery
from pytubefix.exceptions import PytubeFixError
from urllib.error import HTTPError
parse_args = cli._parse_args
def test_display_p... | out | assert | variable | tests/test_cli.py | test_display_progress_bar | 131 | null | |
JuanBindez/pytubefix | import pytest
def test_order_by(cipher_signature):
"""Ensure :meth:`~pytubefix.StreamQuery.order_by` sorts the list of
:class:`Stream <Stream>` instances in the expected order.
"""
itags = [
s.itag
for s in cipher_signature.streams.filter(type="audio").order_by("itag")
]
expecte... | expected_itags | assert | variable | tests/test_query.py | test_order_by | 70 | null | |
JuanBindez/pytubefix | from unittest import mock
from pytubefix import Channel
@mock.patch('pytubefix.request.get')
def test_init_with_url(request_get, channel_videos_html):
request_get.return_value = channel_videos_html
c = Channel('https://www.youtube.com/c/ProgrammingKnowledge/videos')
assert c.channel_url == 'https://www.yo... | f'{c.channel_url}/videos' | assert | string_literal | tests/contrib/test_channel.py | test_init_with_url | 11 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
def test_caption_query_sequence():
caption1 = Caption(
{"url": "url1", "name": {"simpleText": "name1"}, "languageCode": "en", "vssId": ".en"}
)
... | caption2 | assert | variable | tests/test_captions.py | test_caption_query_sequence | 26 | null | |
JuanBindez/pytubefix | from unittest import mock
import pytest
import pytubefix
from pytubefix import YouTube
from pytubefix.exceptions import RegexMatchError
@mock.patch("pytubefix.request.get")
def test_video_unavailable(get):
get.return_value = ""
youtube = YouTube("https://www.youtube.com/watch?v=9bZkp7q19f0")
with pytest... | RegexMatchError) | pytest.raises | variable | tests/test_main.py | test_video_unavailable | 24 | null | |
JuanBindez/pytubefix | import pytest
from unittest import mock
import pytubefix.exceptions as exceptions
from pytubefix import YouTube
from pytubefix.helpers import strip_color_codes
def test_raises_video_private(private):
with mock.patch('pytubefix.request.urlopen') as mock_url_open:
# Mock the responses to YouTube
moc... | exceptions.VideoPrivate) | pytest.raises | complex_expr | tests/test_exceptions.py | test_raises_video_private | 76 | null | |
JuanBindez/pytubefix | import os
import random
import pytest
from datetime import datetime
from unittest import mock
from unittest.mock import MagicMock, Mock
from urllib.error import HTTPError
from pytubefix import request, Stream
def test_segmented_only_catches_404(cipher_signature):
stream = cipher_signature.streams.filter(adaptive=... | HTTPError) | pytest.raises | variable | tests/test_streams.py | test_segmented_only_catches_404 | 388 | null | |
JuanBindez/pytubefix | import os
import pytest
from unittest import mock
from unittest.mock import MagicMock, mock_open, patch
from pytubefix import Caption, CaptionQuery, captions
@mock.patch("pytubefix.captions.Caption.generate_srt_captions")
def test_download_with_output_path(srt):
open_mock = mock_open()
captions.target_directo... | "blah") | assert_* | string_literal | tests/test_captions.py | test_download_with_output_path | 110 | null | |
JuanBindez/pytubefix | import pytest
from unittest import mock
import pytubefix.exceptions as exceptions
from pytubefix import YouTube
from pytubefix.helpers import strip_color_codes
def test_live_stream_error():
# Ensure this can be caught as generic VideoUnavailable exception
with pytest.raises(exceptions.VideoUnavailable):
... | 'YLnZklYFe7E is streaming live and cannot be loaded' | assert | string_literal | tests/test_exceptions.py | test_live_stream_error | 32 | null | |
xflr6/graphviz | import pytest
import graphviz
DEFAULT_ENGINE = 'dot'
DEFAULT_FORMAT = 'pdf'
DEFAULT_JUPYTER_FORMAT = 'svg'
DEFAULT_JUPYTER_MIMETYPE = 'image/svg+xml'
def test_set_jupyter_format(monkeypatch, *, jupyter_format='jpg',
expected_old_format='svg',
expected_normal... | DEFAULT_JUPYTER_MIMETYPE | assert | variable | tests/test_init.py | test_set_jupyter_format | 105 | null | |
xflr6/graphviz | import itertools
import pytest
import graphviz
BASE_GRAPHS = [graphviz.Graph, graphviz.Digraph]
def cls(request):
return request.param
def classes(request):
return request.param
@pytest.mark.parametrize(
'keep_attrs', [False, True])
def test_clear(cls, keep_attrs):
kwargs = {f'{a}_attr': {a: a} fo... | [] | assert | collection | tests/test_graphs.py | test_clear | 76 | null | |
xflr6/graphviz | import contextlib
import pathlib
import os
import shutil
import subprocess
import pytest
import graphviz
from graphviz import _tools
from graphviz.backend import rendering
import _common
TEST_FILES_DIRECTORY = pathlib.Path(__file__).parent.parent
def files_path():
return TEST_FILES_DIRECTORY
@pytest.mark.exe
... | os.fspath(outfile) | assert | func_call | tests/backend/test_rendering.py | test_render_outfile_differnt_parent | 113 | null | |
xflr6/graphviz | import locale
import pathlib
import re
import subprocess
import pytest
import graphviz
import _common
ALL_CLASSES = [graphviz.Graph, graphviz.Digraph, graphviz.Source]
def cls(request):
return request.param
def dot(cls):
if cls.__name__ == 'Source':
return cls('digraph { hello -> world }\n')
r... | encoding) | assert_* | variable | tests/test_all_classes.py | test_pipe_mocked | 266 | null | |
xflr6/graphviz | import errno
import io
import subprocess
import pytest
import graphviz
from graphviz.backend import execute
import _common
def empty_path(monkeypatch):
monkeypatch.setenv('PATH', '')
def test_run_check_called_process_error_mocked(capsys, mock_run, quiet,
stdout='I... | execute.CalledProcessError, match=stderr) | pytest.raises | complex_expr | tests/backend/test_execute.py | test_run_check_called_process_error_mocked | 44 | null | |
xflr6/graphviz | import re
import subprocess
import pytest
import graphviz
import _common
def test_unflatten_stagger_missing():
with pytest.raises( | graphviz.RequiredArgumentError, match=r'without stagger') | pytest.raises | complex_expr | tests/backend/test_unflattening.py | test_unflatten_stagger_missing | 12 | null | |
xflr6/graphviz | import sys
import warnings
import pytest
import graphviz
from graphviz import quoting
@pytest.mark.parametrize(
'char', ['G', 'E', 'T', 'H', 'L', 'l'])
def test_deprecated_escape(recwarn, char):
warnings.simplefilter('always')
escape = eval(rf'"\{char}"')
assert len(recwarn) == | 1 | assert | numeric_literal | tests/test_quoting.py | test_deprecated_escape | 17 | null | |
xflr6/graphviz | import pytest
import graphviz
from graphviz import parameters
VERIFY_FUNCS = [parameters.verify_engine,
parameters.verify_format,
parameters.verify_renderer,
parameters.verify_formatter]
@pytest.mark.parametrize(
'verify_func', VERIFY_FUNCS)
def test_verify_paramet... | ValueError, match=r'unknown .*\(must be .*one of') | pytest.raises | func_call | tests/test_parameters.py | test_verify_parameter_raises_unknown | 44 | null | |
xflr6/graphviz | import functools
import os
import warnings
import pytest
from graphviz import _tools
import _common
def itertree(root):
for path, dirs, files in os.walk(root):
base = os.path.relpath(path, root)
rel_path = functools.partial(os.path.join, base if base != '.' else '')
for is_file, names in... | [] | assert | collection | tests/test_tools.py | test_mkdirs | 31 | null | |
xflr6/graphviz | import io
import re
import subprocess
import pytest
import graphviz
import _common
SVG_PATTERN = r'(?s)^<\?xml .+</svg>\s*$'
def test_pipe_pipe_invalid_data_mocked(mocker, sentinel, mock_run, quiet):
mock_sys_stderr = mocker.patch('sys.stderr', autospec=True,
flush=mocker.Moc... | sentinel.encoding) | assert_* | complex_expr | tests/backend/test_piping.py | test_pipe_pipe_invalid_data_mocked | 62 | null | |
xflr6/graphviz | import locale
import pathlib
import re
import subprocess
import pytest
import graphviz
import _common
ALL_CLASSES = [graphviz.Graph, graphviz.Digraph, graphviz.Source]
def cls(request):
return request.param
def dot(cls):
if cls.__name__ == 'Source':
return cls('digraph { hello -> world }\n')
r... | format | assert | variable | tests/test_all_classes.py | test_format_renderer_formatter_mocked | 166 | null | |
xflr6/graphviz | import sys
import warnings
import pytest
import graphviz
from graphviz import quoting
@pytest.mark.parametrize(
'char', ['G', 'E', 'T', 'H', 'L', 'l'])
def test_deprecated_escape(recwarn, char):
warnings.simplefilter('always')
escape = eval(rf'"\{char}"')
assert len(recwarn) == 1
w = recwarn.po... | str(w.message) | assert | func_call | tests/test_quoting.py | test_deprecated_escape | 20 | null | |
xflr6/graphviz | import pytest
import graphviz
DEFAULT_ENGINE = 'dot'
DEFAULT_FORMAT = 'pdf'
DEFAULT_JUPYTER_FORMAT = 'svg'
DEFAULT_JUPYTER_MIMETYPE = 'image/svg+xml'
def test_set_default_engine(monkeypatch, *, engine='neato', explicit_engine='sfdp'):
assert len({DEFAULT_ENGINE, engine, explicit_engine}) == 3
from graphv... | DEFAULT_ENGINE | assert | variable | tests/test_init.py | test_set_default_engine | 28 | null | |
xflr6/graphviz | import functools
import os
import warnings
import pytest
from graphviz import _tools
import _common
def itertree(root):
for path, dirs, files in os.walk(root):
base = os.path.relpath(path, root)
rel_path = functools.partial(os.path.join, base if base != '.' else '')
for is_file, names in... | result | assert | variable | tests/test_tools.py | test_deprecate_positional_args | 51 | null | |
xflr6/graphviz | import sys
import warnings
import pytest
import graphviz
from graphviz import quoting
@pytest.mark.parametrize(
'identifier, expected',
[('"spam"', r'"\"spam\""'),
('node', '"node"'),
('EDGE', '"EDGE"'),
('Graph', '"Graph"'),
('\\G \\N \\E \\T \\H \\L', '"\\G \\N \\E \\T \\H \\L"'),
... | expected | assert | variable | tests/test_quoting.py | test_quote | 42 | null | |
xflr6/graphviz | import contextlib
import pathlib
import os
import shutil
import subprocess
import pytest
import graphviz
from graphviz import _tools
from graphviz.backend import rendering
import _common
TEST_FILES_DIRECTORY = pathlib.Path(__file__).parent.parent
def files_path():
return TEST_FILES_DIRECTORY
@pytest.mark.para... | expected_fspath | assert | variable | tests/backend/test_rendering.py | test_get_outfile | 180 | null | |
xflr6/graphviz | import locale
import pytest
import graphviz
SOURCE = {'source': 'digraph { hello -> world }\n',
'filename': 'hello.gv', 'directory': 'test-output',
'format': 'PNG', 'engine': 'NEATO', 'encoding': 'utf-8'}
def source():
return graphviz.Source(**SOURCE)
def test_from_file(tmp_path, filename='... | 'utf-8' | assert | string_literal | tests/test_sources.py | test_from_file | 53 | null | |
xflr6/graphviz | import subprocess
import pytest
import graphviz
def test_view_mocked(mocker, mock_platform, mock_popen, mock_startfile, quiet):
assert graphviz.view('nonfilepath', quiet=quiet) is None
if mock_platform == 'windows':
mock_startfile.assert_called_once_with('nonfilepath')
return
if quiet:
... | ['xdg-open', 'nonfilepath']) | assert_* | collection | tests/backend/test_viewing.py | test_view_mocked | 29 | null | |
xflr6/graphviz | import locale
import pytest
import graphviz
SOURCE = {'source': 'digraph { hello -> world }\n',
'filename': 'hello.gv', 'directory': 'test-output',
'format': 'PNG', 'engine': 'NEATO', 'encoding': 'utf-8'}
def source():
return graphviz.Source(**SOURCE)
def test_filepath(platform, source):
... | 'test-output/hello.gv' | assert | string_literal | tests/test_sources.py | test_filepath | 41 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.