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 |
|---|---|---|---|---|---|---|---|---|---|
prkumar/uplink | import contextlib
import pytest
from uplink.clients import (
interfaces,
io,
register,
requests_,
twisted_,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
setattr(obj, attr,... | "client" | assert | string_literal | tests/unit/test_clients.py | test_get_default_client_with_non_callable | 35 | null | |
prkumar/uplink | import pytest
from uplink import arguments, commands, converters, utils
class TestURIDefinitionBuilder:
def test_build(self):
uri = commands.URIDefinitionBuilder("/static/path")
assert uri.build() == | "/static/path" | assert | string_literal | tests/unit/test_commands.py | test_build | TestURIDefinitionBuilder | 120 | null |
prkumar/uplink | import asyncio
import contextlib
import aiohttp
import pytest
from uplink.clients import (
AiohttpClient,
aiohttp_,
io,
register,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
... | response | assert | variable | tests/unit/test_aiohttp_client.py | test_threaded_callback | TestAiohttp | 139 | null |
prkumar/uplink | import pytest
from uplink import helpers
class TestRequestBuilder:
def test_relative_url_template_type_error(self):
# Setup
builder = helpers.RequestBuilder(None, {}, "base_url")
# Run
with pytest.raises( | TypeError) | pytest.raises | variable | tests/unit/test_helpers.py | test_relative_url_template_type_error | TestRequestBuilder | 76 | null |
prkumar/uplink | import pytest
from uplink import helpers
def test_get_api_definitions(request_definition_builder):
class Service:
builder = request_definition_builder
assert dict(helpers.get_api_definitions(Service)) == | { "builder": request_definition_builder } | assert | collection | tests/unit/test_helpers.py | test_get_api_definitions | 11 | null | |
prkumar/uplink | import contextlib
import pytest
from uplink.clients import (
interfaces,
io,
register,
requests_,
twisted_,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
setattr(obj, attr,... | exceptions.ConnectionError) | pytest.raises | complex_expr | tests/unit/test_clients.py | test_exceptions | TestRequests | 131 | null |
prkumar/uplink | import pytest
import uplink
BASE_URL = "https://api.github.com/"
def test_list_repo(mock_client):
github = GitHubService(base_url=BASE_URL, client=mock_client)
github.list_repos("prkumar")
request = mock_client.history[0]
assert request.method == | "GET" | assert | string_literal | tests/integration/test_basic.py | test_list_repo | 49 | null | |
prkumar/uplink | import asyncio
import contextlib
import aiohttp
import pytest
from uplink.clients import (
AiohttpClient,
aiohttp_,
io,
register,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
... | not_a_coroutine | assert | variable | tests/unit/test_aiohttp_client.py | test_threaded_response | TestAiohttp | 186 | null |
prkumar/uplink | from uplink import utils
def test_get_arg_spec():
def func(pos1, *args: 2, **kwargs: 3) -> 4:
pass
signature = utils.get_arg_spec(func)
assert isinstance(signature, utils.Signature)
assert signature.args == | ["pos1", "args", "kwargs"] | assert | collection | tests/unit/test_utils.py | test_get_arg_spec | 13 | null | |
prkumar/uplink | import pytest
from uplink import auth, builder, converters, exceptions, helpers
from uplink.clients import io
def fake_service_cls(request_definition_builder, request_definition):
class Service:
builder = request_definition_builder
request_definition_builder.build.return_value = request_definition
... | request_builder) | assert_* | variable | tests/unit/test_builder.py | test_prepare_request_with_transaction_hook | TestRequestPreparer | 57 | null |
prkumar/uplink | import pytest
from uplink import arguments, commands, converters, utils
class TestHttpMethod:
def test_call_with_args(self, mocker, annotation_mock):
# Setup
def func():
pass
args = mocker.patch("uplink.decorators.args")
# Verify: using sequence
http_method =... | annotation_mock) | assert_* | variable | tests/unit/test_commands.py | test_call_with_args | TestHttpMethod | 77 | null |
prkumar/uplink | import collections
import pytest
from uplink import decorators, interfaces
def method_annotation():
return decorators.MethodAnnotation()
def method_annotation_mock(mocker):
return mocker.Mock(spec=decorators.MethodAnnotation)
def method_handler_builder():
return decorators.MethodAnnotationHandlerBuilde... | 1 | assert | numeric_literal | tests/unit/test_decorators.py | test_json | 208 | null | |
prkumar/uplink | import pytest
from uplink import auth, builder, converters, exceptions, helpers
from uplink.clients import io
def fake_service_cls(request_definition_builder, request_definition):
class Service:
builder = request_definition_builder
request_definition_builder.build.return_value = request_definition
... | uplink_builder.client) | assert_* | complex_expr | tests/unit/test_builder.py | test_prepare_request | TestRequestPreparer | 40 | null |
prkumar/uplink | import contextlib
import pytest
from uplink.clients import (
interfaces,
io,
register,
requests_,
twisted_,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
setattr(obj, attr,... | twisted_client.exceptions | assert | complex_expr | tests/unit/test_clients.py | test_exceptions | TestTwisted | 183 | null |
prkumar/uplink | import collections
import pytest
from uplink import decorators, interfaces
def method_annotation():
return decorators.MethodAnnotation()
def method_annotation_mock(mocker):
return mocker.Mock(spec=decorators.MethodAnnotation)
def method_handler_builder():
return decorators.MethodAnnotationHandlerBuilde... | {"param": "value"} | assert | collection | tests/unit/test_decorators.py | test_params | 164 | null | |
prkumar/uplink | import pytest
from uplink.clients.io import interfaces, state, transitions
def request_execution_mock(mocker):
return mocker.Mock(spec=interfaces.RequestExecution)
def request_state_mock(mocker):
return mocker.Mock(spec=interfaces.RequestState)
class BasicStateTest:
def create_state(self, request):
... | state.BeforeRequest(request) | assert | func_call | tests/unit/test_io.py | test_prepare | BasicStateTest | 30 | null |
prkumar/uplink | from uplink import returns
def test_returns_JsonStrategy(mocker):
response = mocker.Mock(spec=["json"])
response.json.return_value = {"hello": "world"}
converter = returns.JsonStrategy(lambda x: x, "hello")
assert converter(response) == "world"
converter = returns.JsonStrategy(lambda y: y + "!", "... | "world!" | assert | string_literal | tests/unit/test_returns.py | test_returns_JsonStrategy | 118 | null | |
prkumar/uplink | import pytest
from uplink import hooks
class TestTransactionHookChain:
def test_delegate_handle_response_multiple(self, mocker):
# Include one hook that can't handle responses
mock_response_handler = mocker.Mock()
mock_request_auditor = mocker.Mock()
chain = hooks.TransactionHook... | 2 | assert | numeric_literal | tests/unit/test_hooks.py | test_delegate_handle_response_multiple | TestTransactionHookChain | 55 | null |
prkumar/uplink | import pytest
from uplink import auth, builder, converters, exceptions, helpers
from uplink.clients import io
def fake_service_cls(request_definition_builder, request_definition):
class Service:
builder = request_definition_builder
request_definition_builder.build.return_value = request_definition
... | execution_builder.build().start.return_value | assert | func_call | tests/unit/test_builder.py | test_call | TestCallFactory | 95 | null |
prkumar/uplink | import pytest
from uplink.clients.io import interfaces, state, transitions
def request_execution_mock(mocker):
return mocker.Mock(spec=interfaces.RequestExecution)
def request_state_mock(mocker):
return mocker.Mock(spec=interfaces.RequestState)
class BasicStateTest:
def create_state(self, request):
... | state.Fail(request, Exception, error, None) | assert | func_call | tests/unit/test_io.py | test_fail | BasicStateTest | 43 | null |
prkumar/uplink | import pytest
from uplink import auth, utils
class TestMultiAuth:
def setup_basic_auth(self):
return auth.BasicAuth("apiuser", "apipass")
def verify_basic_auth(self, basic_auth, request_builder):
basic_auth_str = basic_auth._header_value
assert request_builder.info["headers"]["Authori... | proxy_auth | assert | variable | tests/unit/test_auth.py | test_four_methods | TestMultiAuth | 175 | null |
prkumar/uplink | import pytest
from uplink import auth, utils
class TestMultiAuth:
def setup_basic_auth(self):
return auth.BasicAuth("apiuser", "apipass")
def verify_basic_auth(self, basic_auth, request_builder):
basic_auth_str = basic_auth._header_value
assert request_builder.info["headers"]["Authori... | 2 | assert | numeric_literal | tests/unit/test_auth.py | test_append | TestMultiAuth | 191 | null |
prkumar/uplink | import pytest
from uplink import arguments, hooks
from uplink.converters import keys
inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]])
def argument_mock(mocker):
return mocker.Mock(spec=arguments.ArgumentAnnotation)
def named_argument_mock(mocker):
return mocker.Mock(spec=arguments.N... | "name") | assert_* | string_literal | tests/unit/test_arguments.py | test_modify_request_definition | TestPath | 237 | null |
prkumar/uplink | import pytest
import uplink
BASE_URL = "https://api.github.com/"
def test_get_repo(mock_client, mock_response):
"""
This integration test ensures that the returns.json returns the
Json body when a model is not provided.
"""
# Setup: return a mock response
expected_json = {"key": "value"}
... | actual_json | assert | variable | tests/integration/test_basic.py | test_get_repo | 71 | null | |
prkumar/uplink | from uplink import returns
def test_returns_json_builtin_type(request_builder, mocker):
mock_response = mocker.Mock()
mock_response.json.return_value = {"key": "1"}
request_builder.get_converter.return_value = None
returns_json = returns.json(type=int, key="key")
request_builder.return_type = retur... | 1 | assert | numeric_literal | tests/unit/test_returns.py | test_returns_json_builtin_type | 68 | null | |
prkumar/uplink | from uplink import utils
class TestURIBuilder:
def test_remaining_variables(self):
builder = utils.URIBuilder("{variable}")
assert builder.remaining_variables() == | {"variable"} | assert | collection | tests/unit/test_utils.py | test_remaining_variables | TestURIBuilder | 38 | null |
prkumar/uplink | import pytest
from uplink.clients.io import interfaces, state, transitions
def request_execution_mock(mocker):
return mocker.Mock(spec=interfaces.RequestExecution)
def request_state_mock(mocker):
return mocker.Mock(spec=interfaces.RequestState)
class TestFail:
def test_execute(self, request_execution_mo... | None) | assert_* | none_literal | tests/unit/test_io.py | test_execute | TestFail | 127 | null |
prkumar/uplink | import asyncio
import contextlib
import aiohttp
import pytest
from uplink.clients import (
AiohttpClient,
aiohttp_,
io,
register,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
... | exceptions.ServerTimeout) | pytest.raises | complex_expr | tests/unit/test_aiohttp_client.py | test_exceptions | TestAiohttp | 250 | null |
prkumar/uplink | from uplink import retry
from uplink.retry import backoff, stop, when
def test_exponential_backoff_minimum():
iterator = backoff.exponential(base=2, minimum=8)()
assert next(iterator) == | 8 | assert | numeric_literal | tests/unit/test_retry.py | test_exponential_backoff_minimum | 27 | null | |
prkumar/uplink | import pytest
from uplink import hooks
class TestExceptionHandler:
def test_handle_exception_masked(self, mocker):
handler = mocker.Mock()
eh = hooks.ExceptionHandler(handler)
eh.handle_exception("consumer", "exc_type", "exc_val", "exc_tb")
handler.assert_called_with("exc_type", "... | "exc_tb") | assert_* | string_literal | tests/unit/test_hooks.py | test_handle_exception_masked | TestExceptionHandler | 30 | null |
prkumar/uplink | import pytest
from uplink import arguments, hooks
from uplink.converters import keys
inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]])
def argument_mock(mocker):
return mocker.Mock(spec=arguments.ArgumentAnnotation)
def named_argument_mock(mocker):
return mocker.Mock(spec=arguments.N... | "world" | assert | string_literal | tests/unit/test_arguments.py | test_modify_request | TestField | 333 | null |
prkumar/uplink | from uplink import utils
class TestURIBuilder:
def test_variables_not_string(self):
assert utils.URIBuilder.variables(None) == | set() | assert | func_call | tests/unit/test_utils.py | test_variables_not_string | TestURIBuilder | 28 | null |
prkumar/uplink | import contextlib
import pytest
from uplink.clients import (
interfaces,
io,
register,
requests_,
twisted_,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
setattr(obj, attr,... | exceptions.ServerTimeout) | pytest.raises | complex_expr | tests/unit/test_clients.py | test_exceptions | TestRequests | 137 | null |
prkumar/uplink | import contextlib
import pytest
from uplink.clients import (
interfaces,
io,
register,
requests_,
twisted_,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
setattr(obj, attr,... | NotImplementedError) | pytest.raises | variable | tests/unit/test_clients.py | test_create_requests_no_twisted | TestTwisted | 157 | null |
prkumar/uplink | from uplink import retry
from uplink.retry import backoff, stop, when
def test_compose_backoff(mocker):
left = backoff.from_iterable([0, 1])
right = backoff.from_iterable([2])
mocker.spy(left, "handle_after_final_retry")
mocker.spy(right, "handle_after_final_retry")
strategy = left | right
# S... | 0 | assert | numeric_literal | tests/unit/test_retry.py | test_compose_backoff | 46 | null | |
prkumar/uplink | from uplink import Consumer, PartMap, multipart, post
BASE_URL = "https://example.com/"
def test_without_converter(mock_response, mock_client):
class Calendar(Consumer):
@multipart
@post("/attachments", args={"files": PartMap})
def upload_attachments(self, **files):
pass
m... | {"file": file} | assert | collection | tests/integration/test_multipart.py | test_without_converter | 24 | null | |
prkumar/uplink | import pytest
import uplink
from uplink.ratelimit import RateLimitExceeded, now
BASE_URL = "https://api.github.com/"
DIFFERENT_BASE_URL = "https://hostedgithub.com/"
def test_exceeded_limit_wait(mock_client):
# Setup
github = GitHub(base_url=BASE_URL, client=mock_client)
# Run
start = now()
gith... | 1 | assert | numeric_literal | tests/integration/test_ratelimit.py | test_exceeded_limit_wait | 81 | null | |
prkumar/uplink | import pytest
import uplink
BASE_URL = "https://api.github.com/"
def test_list_repo(mock_client):
github = GitHubService(base_url=BASE_URL, client=mock_client)
github.list_repos("prkumar")
request = mock_client.history[0]
assert request.method == "GET"
assert request.has_base_url(BASE_URL)
as... | 15 | assert | numeric_literal | tests/integration/test_basic.py | test_list_repo | 53 | null | |
prkumar/uplink | import pytest
from uplink import helpers
class TestRequestBuilder:
def test_add_transaction_hook(self, transaction_hook_mock):
# Setup
builder = helpers.RequestBuilder(None, {}, "base_url")
# Run
builder.add_transaction_hook(transaction_hook_mock)
# Verify
asser... | [transaction_hook_mock] | assert | collection | tests/unit/test_helpers.py | test_add_transaction_hook | TestRequestBuilder | 48 | null |
prkumar/uplink | import asyncio
import contextlib
import aiohttp
import pytest
from uplink.clients import (
AiohttpClient,
aiohttp_,
io,
register,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
... | exceptions.SSLError) | pytest.raises | complex_expr | tests/unit/test_aiohttp_client.py | test_exceptions | TestAiohttp | 253 | null |
prkumar/uplink | import collections
import uplink
BASE_URL = "https://api.github.com/"
User = collections.namedtuple("User", "id name")
Repo = collections.namedtuple("Repo", "owner name")
def user_reader(cls, response):
return cls(**response.json())
def repo_json_reader(cls, json):
return cls(**json)
def repo_json_writer(... | repo | assert | variable | tests/integration/test_returns.py | test_returns_json_with_type | 132 | null | |
prkumar/uplink | from uplink import session
def test_headers(uplink_builder_mock):
# Setup
sess = session.Session(uplink_builder_mock)
# Run
sess.headers["key"] = "value"
# Verify
assert uplink_builder_mock.add_hook.called
assert sess.headers == | {"key": "value"} | assert | collection | tests/unit/test_session.py | test_headers | 23 | null | |
prkumar/uplink | import pytest
from uplink import arguments, hooks
from uplink.converters import keys
inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]])
def argument_mock(mocker):
return mocker.Mock(spec=arguments.ArgumentAnnotation)
def named_argument_mock(mocker):
return mocker.Mock(spec=arguments.N... | "value" | assert | string_literal | tests/unit/test_arguments.py | test_modify_request | TestContext | 425 | null |
prkumar/uplink | import pytest
from uplink import arguments, hooks
from uplink.converters import keys
inject_args = pytest.mark.parametrize("args", [["arg1", "arg2", "arg3"]])
def argument_mock(mocker):
return mocker.Mock(spec=arguments.ArgumentAnnotation)
def named_argument_mock(mocker):
return mocker.Mock(spec=arguments.N... | "name" | assert | string_literal | tests/unit/test_arguments.py | test_name | TestNamedArgument | 215 | null |
prkumar/uplink | import sys
import marshmallow
import pytest
from uplink import converters
from uplink.converters import register, standard
def schema_mock_and_argument(request, mocker):
class Schema(marshmallow.Schema):
def __new__(cls, *args, **kwargs):
return schema
schema = mocker.Mock(spec=marshmal... | data) | assert_* | variable | tests/unit/test_converters.py | test_create_response_body_converter | TestMarshmallowConverter | 222 | null |
prkumar/uplink | import pytest
from uplink import auth, utils
class TestMultiAuth:
def setup_basic_auth(self):
return auth.BasicAuth("apiuser", "apipass")
def verify_basic_auth(self, basic_auth, request_builder):
basic_auth_str = basic_auth._header_value
assert request_builder.info["headers"]["Authori... | 4 | assert | numeric_literal | tests/unit/test_auth.py | test_four_methods | TestMultiAuth | 171 | null |
prkumar/uplink | import sys
import marshmallow
import pytest
from uplink import converters
from uplink.converters import register, standard
def schema_mock_and_argument(request, mocker):
class Schema(marshmallow.Schema):
def __new__(cls, *args, **kwargs):
return schema
schema = mocker.Mock(spec=marshmal... | [] | assert | collection | tests/unit/test_converters.py | test_register | TestMarshmallowConverter | 281 | null |
prkumar/uplink | import pytest
import pytest_twisted
from uplink import Consumer, get, retry
from uplink.clients import io
BASE_URL = "https://api.github.com/"
def backoff_once():
yield 0.1
def test_retry(mock_client, mock_response):
# Setup
mock_response.with_json({"id": 123, "name": "prkumar"})
mock_client.with_si... | 2 | assert | numeric_literal | tests/integration/test_retry.py | test_retry | 58 | null | |
prkumar/uplink | from uplink import utils
def test_call_args():
def func(pos1, *args, **kwargs):
pass
call_args = utils.get_call_args(func, 1, 2, named=3)
assert call_args == | {"pos1": 1, "args": (2,), "kwargs": {"named": 3}} | assert | collection | tests/unit/test_utils.py | test_call_args | 23 | null | |
prkumar/uplink | import pytest
import pytest_twisted
from uplink import Consumer, get, retry
from uplink.clients import io
BASE_URL = "https://api.github.com/"
def backoff_once():
yield 0.1
def test_retry_fail(mock_client, mock_response):
# Setup
mock_response.with_json({"id": 123, "name": "prkumar"})
mock_client.wi... | CustomException) | pytest.raises | variable | tests/integration/test_retry.py | test_retry_fail | 69 | null | |
prkumar/uplink | import pytest
from uplink.clients.io import interfaces, state, transitions
def request_execution_mock(mocker):
return mocker.Mock(spec=interfaces.RequestExecution)
def request_state_mock(mocker):
return mocker.Mock(spec=interfaces.RequestState)
class BasicStateTest:
def create_state(self, request):
... | state.Sleep(request, 10) | assert | func_call | tests/unit/test_io.py | test_sleep | BasicStateTest | 56 | null |
prkumar/uplink | from uplink import retry
from uplink.retry import backoff, stop, when
def test_compose_backoff(mocker):
left = backoff.from_iterable([0, 1])
right = backoff.from_iterable([2])
mocker.spy(left, "handle_after_final_retry")
mocker.spy(right, "handle_after_final_retry")
strategy = left | right
# S... | 2 | assert | numeric_literal | tests/unit/test_retry.py | test_compose_backoff | 48 | null | |
prkumar/uplink | import collections
import pytest
from uplink import decorators, interfaces
def method_annotation():
return decorators.MethodAnnotation()
def method_annotation_mock(mocker):
return mocker.Mock(spec=decorators.MethodAnnotation)
def method_handler_builder():
return decorators.MethodAnnotationHandlerBuilde... | handler) | assert_* | variable | tests/unit/test_decorators.py | test_response_handler | 284 | null | |
prkumar/uplink | import pytest
from uplink import helpers
class TestRequestBuilder:
def test_return_type(self):
# Setup
builder = helpers.RequestBuilder(None, {}, "base_url")
# Run
builder.return_type = str
# Verify
assert builder.return_type is | str | assert | variable | tests/unit/test_helpers.py | test_return_type | TestRequestBuilder | 38 | null |
prkumar/uplink | from uplink import returns
class TestReturnsJsonCast:
default_value = {"key": "1"}
def prepare_test(request_builder, mocker, value=default_value, **kwargs):
mock_response = mocker.Mock()
mock_response.json.return_value = value
request_builder.get_converter.return_value = None
r... | str(self.default_value) | assert | func_call | tests/unit/test_returns.py | test_with_builtin_type | TestReturnsJsonCast | 100 | null |
prkumar/uplink | import collections
import pytest
from uplink import decorators, interfaces
def method_annotation():
return decorators.MethodAnnotation()
def method_annotation_mock(mocker):
return mocker.Mock(spec=decorators.MethodAnnotation)
def method_handler_builder():
return decorators.MethodAnnotationHandlerBuilde... | annotation) | assert_* | variable | tests/unit/test_decorators.py | test_args_call_old | 275 | null | |
prkumar/uplink | import asyncio
import contextlib
import aiohttp
import pytest
from uplink.clients import (
AiohttpClient,
aiohttp_,
io,
register,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
... | 2 | assert | numeric_literal | tests/unit/test_aiohttp_client.py | test_callback | TestAiohttp | 101 | null |
prkumar/uplink | import asyncio
import contextlib
import aiohttp
import pytest
from uplink.clients import (
AiohttpClient,
aiohttp_,
io,
register,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
... | NotImplementedError) | pytest.raises | variable | tests/unit/test_aiohttp_client.py | test_init_when_aiohttp_is_not_installed | TestAiohttp | 52 | null |
prkumar/uplink | import pytest
import uplink
BASE_URL = "https://api.github.com/"
def test_handle_client_exceptions(mock_client):
# Setup: mock client exceptions
class MockBaseClientException(Exception):
pass
class MockInvalidURL(MockBaseClientException):
pass
mock_client.exceptions.BaseClientExcep... | service.exceptions.InvalidURL) | pytest.raises | complex_expr | tests/integration/test_basic.py | test_handle_client_exceptions | 108 | null | |
prkumar/uplink | import pytest
import uplink
BASE_URL = "https://api.github.com/"
def test_list_repo_wrapper(mock_client):
"""Ensures that the consumer method looks like the original func."""
github = GitHubService(base_url=BASE_URL, client=mock_client)
assert (
github.list_repos.__doc__
== GitHubService.... | GitHubService.list_repos.__name__ | assert | complex_expr | tests/integration/test_basic.py | test_list_repo_wrapper | 40 | null | |
prkumar/uplink | import pytest
import uplink
BASE_URL = "https://api.github.com/"
def test_list_repo(mock_client):
github = GitHubService(base_url=BASE_URL, client=mock_client)
github.list_repos("prkumar")
request = mock_client.history[0]
assert request.method == "GET"
assert request.has_base_url(BASE_URL)
as... | {"Accept": "application/vnd.github.v3.full+json"} | assert | collection | tests/integration/test_basic.py | test_list_repo | 52 | null | |
prkumar/uplink | import asyncio
import contextlib
import aiohttp
import pytest
from uplink.clients import (
AiohttpClient,
aiohttp_,
io,
register,
)
def _patch(obj, attr, value):
if obj is not None:
old_value = getattr(obj, attr)
setattr(obj, attr, value)
yield
if obj is not None:
... | *positionals) | assert_* | complex_expr | tests/unit/test_aiohttp_client.py | test_create | TestAiohttp | 204 | null |
prkumar/uplink | import pytest
from uplink import hooks
class TestRequestAuditor:
def test_audit_request(self, mocker):
auditor = mocker.Mock()
ra = hooks.RequestAuditor(auditor)
ra.audit_request("consumer", "request")
auditor.assert_called_with( | "request") | assert_* | string_literal | tests/unit/test_hooks.py | test_audit_request | TestRequestAuditor | 22 | null |
prkumar/uplink | import sys
import marshmallow
import pytest
from uplink import converters
from uplink.converters import register, standard
def schema_mock_and_argument(request, mocker):
class Schema(marshmallow.Schema):
def __new__(cls, *args, **kwargs):
return schema
schema = mocker.Mock(spec=marshmal... | "1" | assert | string_literal | tests/unit/test_converters.py | test_convert_not_sequence | TestSequence | 335 | null |
prkumar/uplink | import pytest
from uplink import arguments, commands, converters, utils
class TestURIDefinitionBuilder:
def test_add_variable(self):
uri = commands.URIDefinitionBuilder("/path/with/{variable}")
assert "variable" in | uri.remaining_variables | assert | complex_expr | tests/unit/test_commands.py | test_add_variable | TestURIDefinitionBuilder | 109 | null |
prkumar/uplink | from uplink import retry
from uplink.retry import backoff, stop, when
def test_retry_decorator_exposes_submodules_as_properties():
assert retry.backoff is backoff
assert retry.stop is stop
assert retry.when is | when | assert | variable | tests/unit/test_retry.py | test_retry_decorator_exposes_submodules_as_properties | 101 | null | |
gabrieldemarmiesse/python-on-whales | import datetime as dt
import json
import re
from pathlib import Path
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.pod.models import PodInspectResult
from python_on_whales.exceptions import NoSuchPod
from python_on_whales.test_utils import get_all_jsons, random_name
def tes... | pod | assert | variable | tests/python_on_whales/components/test_pod.py | test_inspect | 67 | null | |
gabrieldemarmiesse/python-on-whales | import json
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.container.models import ContainerEndpointIPAMConfig
from python_on_whales.components.network.cli_wrapper import NetworkInspectResult
from python_on_whales.exceptions import DockerException
from python_on_whales.test_u... | [network] | assert | collection | tests/python_on_whales/components/test_network.py | test_list_filters | 103 | null | |
gabrieldemarmiesse/python-on-whales | import json
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.container.models import ContainerEndpointIPAMConfig
from python_on_whales.components.network.cli_wrapper import NetworkInspectResult
from python_on_whales.exceptions import DockerException
from python_on_whales.test_u... | set(ctr_client.network.list()) | assert | func_call | tests/python_on_whales/components/test_network.py | test_remove_nothing | 70 | null | |
gabrieldemarmiesse/python-on-whales | import json
from datetime import datetime, timedelta, timezone
from pathlib import Path
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.volume.models import VolumeInspectResult
from python_on_whales.exceptions import NoSuchVolume
from python_on_whales.test_utils import get_all... | "Hello\nWorld!" | assert | string_literal | tests/python_on_whales/components/test_volume.py | test_copy_to_and_from_volume | 187 | null | |
gabrieldemarmiesse/python-on-whales | import json
import tempfile
import time
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.service.models import ServiceInspectResult
from python_on_whales.exceptions import NoSuchService, NotASwarmManager
from python_on_whales.test_utils import get_all_jsons, random_name
@pytes... | "running" | assert | string_literal | tests/python_on_whales/components/test_service.py | test_tasks | 26 | null | |
gabrieldemarmiesse/python-on-whales | import json
import os
import signal
import sys
import tempfile
import time
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Literal, Union
from unittest.mock import Mock, patch
import pytest
import python_on_whales
from python_on_whales import DockerClient, Image, docker
... | 100 | assert | numeric_literal | tests/python_on_whales/components/test_container.py | test_load_stats_json | 733 | null | |
gabrieldemarmiesse/python-on-whales | import json
from contextlib import contextmanager
from pathlib import Path
from typing import Iterator, Sequence, Tuple
import pytest
from python_on_whales import DockerClient, docker
from python_on_whales.client_config import ClientConfig, ParsingError
from python_on_whales.utils import PROJECT_ROOT
fake_json_messa... | env_file | assert | variable | tests/python_on_whales/test_client_config.py | test_compose_env_files | 74 | null | |
gabrieldemarmiesse/python-on-whales | import json
import time
from datetime import date, datetime
from pathlib import Path
from time import sleep
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.system.models import DockerEvent, SystemInfo
from python_on_whales.exceptions import DockerException
from python_on_whale... | 2000 | assert | numeric_literal | tests/python_on_whales/components/test_system.py | test_disk_free | 33 | null | |
gabrieldemarmiesse/python-on-whales | import json
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.container.models import ContainerEndpointIPAMConfig
from python_on_whales.components.network.cli_wrapper import NetworkInspectResult
from python_on_whales.exceptions import DockerException
from python_on_whales.test_u... | ctr_client.network.list() | assert | func_call | tests/python_on_whales/components/test_network.py | test_context_manager | 49 | null | |
gabrieldemarmiesse/python-on-whales | import pytest
from python_on_whales import docker
from python_on_whales.utils import PROJECT_ROOT
bake_test_dir = PROJECT_ROOT / "tests/python_on_whales/components/bake_tests"
bake_file = bake_test_dir / "docker-bake.hcl"
def test_imagetools_create_annotations_type_validation():
with pytest.raises(TypeError) as ... | str(err.value) | assert | func_call | tests/python_on_whales/components/buildx/imagetools/test_imagetools_cli_wrapper.py | test_imagetools_create_annotations_type_validation | 80 | null | |
gabrieldemarmiesse/python-on-whales | import json
from contextlib import contextmanager
from pathlib import Path
from typing import Iterator, Sequence, Tuple
import pytest
from python_on_whales import DockerClient, docker
from python_on_whales.client_config import ClientConfig, ParsingError
from python_on_whales.utils import PROJECT_ROOT
fake_json_messa... | example_env_file_name | assert | variable | tests/python_on_whales/test_client_config.py | test_compose_env_file | 52 | null | |
gabrieldemarmiesse/python-on-whales | import re
import time
from pathlib import Path
import pytest
from python_on_whales import DockerClient
from python_on_whales.exceptions import DockerException
@pytest.mark.skipif(True, reason="It doesn't work in the ci")
def test_docker_client_options(docker_client: DockerClient):
if docker_client.container.exis... | dind_client.run("hello-world") | assert | func_call | tests/python_on_whales/test_docker_client.py | test_docker_client_options | 60 | null | |
gabrieldemarmiesse/python-on-whales | import json
from datetime import datetime, timedelta, timezone
from pathlib import Path
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.volume.models import VolumeInspectResult
from python_on_whales.exceptions import NoSuchVolume
from python_on_whales.test_utils import get_all... | [vol2] | assert | collection | tests/python_on_whales/components/test_volume.py | test_list_filters | 94 | null | |
gabrieldemarmiesse/python-on-whales | import contextlib
import json
from pathlib import Path
from typing import Generator
from unittest.mock import ANY, MagicMock, Mock, patch
import pytest
from python_on_whales import DockerClient, docker
from python_on_whales.components.image.models import ImageInspectResult
from python_on_whales.exceptions import Dock... | None | assert | none_literal | tests/python_on_whales/components/test_image.py | test_push_nothing | 294 | null | |
gabrieldemarmiesse/python-on-whales | import json
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.context.models import ContextInspectResult
from python_on_whales.test_utils import get_all_jsons
def test_inpect(docker_client: DockerClient):
default_context = docker_client.context.inspect()
assert default_... | b | assert | variable | tests/python_on_whales/components/test_context.py | test_inpect | 40 | null | |
gabrieldemarmiesse/python-on-whales | import json
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.container.models import ContainerEndpointIPAMConfig
from python_on_whales.components.network.cli_wrapper import NetworkInspectResult
from python_on_whales.exceptions import DockerException
from python_on_whales.test_u... | value | assert | variable | tests/python_on_whales/components/test_network.py | test_network_create_with_labels | 33 | null | |
gabrieldemarmiesse/python-on-whales | import json
import shutil
import signal
import tempfile
import time
from datetime import datetime, timedelta
from os import makedirs, remove
from pathlib import Path
from typing import Iterable, Tuple, Union
from unittest.mock import Mock, patch
import pytest
import pytz
import python_on_whales
from python_on_whales ... | 4 | assert | numeric_literal | tests/python_on_whales/components/test_compose.py | test_config_complexe_compose | 718 | null | |
gabrieldemarmiesse/python-on-whales | import json
from contextlib import contextmanager
from pathlib import Path
from typing import Iterator, Sequence, Tuple
import pytest
from python_on_whales import DockerClient, docker
from python_on_whales.client_config import ClientConfig, ParsingError
from python_on_whales.utils import PROJECT_ROOT
fake_json_messa... | error_message | assert | variable | tests/python_on_whales/test_client_config.py | test_pretty_exception_message_and_report | 32 | null | |
gabrieldemarmiesse/python-on-whales | import json
import time
from datetime import date, datetime
from pathlib import Path
from time import sleep
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.system.models import DockerEvent, SystemInfo
from python_on_whales.exceptions import DockerException
from python_on_whale... | ctr_client.network.list() | assert | func_call | tests/python_on_whales/components/test_system.py | test_prune_prunes_network | 165 | null | |
gabrieldemarmiesse/python-on-whales | import json
import tempfile
import time
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.service.models import ServiceInspectResult
from python_on_whales.exceptions import NoSuchService, NotASwarmManager
from python_on_whales.test_utils import get_all_jsons, random_name
@pytes... | {"Replicas": 3} | assert | collection | tests/python_on_whales/components/test_service.py | test_service_scale | 92 | null | |
gabrieldemarmiesse/python-on-whales | import json
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.node.models import NodeInspectResult
from python_on_whales.test_utils import get_all_jsons
@pytest.mark.usefixtures("swarm_mode")
def test_add_label(docker_client: DockerClient):
nodes = docker_client.node.list()... | "bar" | assert | string_literal | tests/python_on_whales/components/test_node.py | test_add_label | 37 | null | |
gabrieldemarmiesse/python-on-whales | import json
import os
from typing import Generator
import pytest
from python_on_whales import DockerClient, Image
from python_on_whales.components.manifest.cli_wrapper import (
ManifestList,
ManifestListInspectResult,
)
from python_on_whales.test_utils import get_all_jsons, random_name
def manifest(docker_cl... | "arm64" | assert | string_literal | tests/python_on_whales/components/test_manifest.py | test_manifest_annotate | 66 | null | |
gabrieldemarmiesse/python-on-whales | import json
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.container.models import ContainerEndpointIPAMConfig
from python_on_whales.components.network.cli_wrapper import NetworkInspectResult
from python_on_whales.exceptions import DockerException
from python_on_whales.test_u... | 2 | assert | numeric_literal | tests/python_on_whales/components/test_network.py | test_swarm_service_create | 81 | null | |
gabrieldemarmiesse/python-on-whales | import json
import os
import tarfile
from pathlib import Path
from unittest.mock import Mock, patch
import pytest
import python_on_whales.components.buildx.cli_wrapper
from python_on_whales import docker
from python_on_whales.exceptions import DockerException
from python_on_whales.test_utils import set_cache_validity... | "" | assert | string_literal | tests/python_on_whales/components/buildx/test_buildx_cli_wrapper.py | test_buildx_build_streaming_logs | 88 | null | |
gabrieldemarmiesse/python-on-whales | import json
from datetime import datetime, timedelta, timezone
from pathlib import Path
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.volume.models import VolumeInspectResult
from python_on_whales.exceptions import NoSuchVolume
from python_on_whales.test_utils import get_all... | "dodo.txt" | assert | string_literal | tests/python_on_whales/components/test_volume.py | test_volume_cp_to_in_dir | 238 | null | |
gabrieldemarmiesse/python-on-whales | import datetime as dt
import json
import re
from pathlib import Path
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.pod.models import PodInspectResult
from python_on_whales.exceptions import NoSuchPod
from python_on_whales.test_utils import get_all_jsons, random_name
def tes... | 2 | assert | numeric_literal | tests/python_on_whales/components/test_pod.py | test_create_with_container | 114 | null | |
gabrieldemarmiesse/python-on-whales | import datetime as dt
import json
import re
from pathlib import Path
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.pod.models import PodInspectResult
from python_on_whales.exceptions import NoSuchPod
from python_on_whales.test_utils import get_all_jsons, random_name
def tes... | "exited" | assert | string_literal | tests/python_on_whales/components/test_pod.py | test_stop_simple | 54 | null | |
gabrieldemarmiesse/python-on-whales | import json
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.node.models import NodeInspectResult
from python_on_whales.test_utils import get_all_jsons
@pytest.mark.parametrize("json_file", get_all_jsons("nodes"))
def test_load_json(json_file):
json_as_txt = json_file.read... | "gpu" | assert | string_literal | tests/python_on_whales/components/test_node.py | test_load_json | 15 | null | |
gabrieldemarmiesse/python-on-whales | import json
import os
import signal
import sys
import tempfile
import time
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Literal, Union
from unittest.mock import Mock, patch
import pytest
import python_on_whales
from python_on_whales import DockerClient, Image, docker
... | 5 | assert | numeric_literal | tests/python_on_whales/components/test_container.py | test_stats_all | 749 | null | |
gabrieldemarmiesse/python-on-whales | import pytest
from python_on_whales import docker
from python_on_whales.utils import PROJECT_ROOT
bake_test_dir = PROJECT_ROOT / "tests/python_on_whales/components/bake_tests"
bake_file = bake_test_dir / "docker-bake.hcl"
def test_imagetools_inspect_single_image():
a = docker.buildx.imagetools.inspect(
"... | 2 | assert | numeric_literal | tests/python_on_whales/components/buildx/imagetools/test_imagetools_cli_wrapper.py | test_imagetools_inspect_single_image | 19 | null | |
gabrieldemarmiesse/python-on-whales | import json
import os
import signal
import sys
import tempfile
import time
from datetime import datetime, timedelta, timezone
from pathlib import Path
from typing import Literal, Union
from unittest.mock import Mock, patch
import pytest
import python_on_whales
from python_on_whales import DockerClient, Image, docker
... | [] | assert | collection | tests/python_on_whales/components/test_container.py | test_stats_cli_empty_selection | 802 | null | |
gabrieldemarmiesse/python-on-whales | import datetime as dt
import json
import re
from pathlib import Path
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.pod.models import PodInspectResult
from python_on_whales.exceptions import NoSuchPod
from python_on_whales.test_utils import get_all_jsons, random_name
def tes... | False | assert | bool_literal | tests/python_on_whales/components/test_pod.py | test_does_not_exist | 107 | null | |
gabrieldemarmiesse/python-on-whales | import json
import tempfile
import time
import pytest
from python_on_whales import DockerClient
from python_on_whales.components.service.models import ServiceInspectResult
from python_on_whales.exceptions import NoSuchService, NotASwarmManager
from python_on_whales.test_utils import get_all_jsons, random_name
@pytes... | list_of_services | assert | variable | tests/python_on_whales/components/test_service.py | test_get_list_of_services | 45 | null | |
gabrieldemarmiesse/python-on-whales | import contextlib
import json
from pathlib import Path
from typing import Generator
from unittest.mock import ANY, MagicMock, Mock, patch
import pytest
from python_on_whales import DockerClient, docker
from python_on_whales.components.image.models import ImageInspectResult
from python_on_whales.exceptions import Dock... | NoSuchImage) | pytest.raises | variable | tests/python_on_whales/components/test_image.py | test_no_such_image_inspect | 391 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.