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 |
|---|---|---|---|---|---|---|---|---|---|
Neoteroi/BlackSheep | import pytest
from essentials.secrets import Secret
from guardpost import Identity
from blacksheep.server.authentication.apikey import (
APIKey,
APIKeyAuthentication,
APIKeyLocation,
APIKeysProvider,
)
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages import Mock... | [] | assert | collection | tests/test_auth_api_key.py | test_api_key_defaults | 64 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep import Header, Headers
def test_iadd_http_header_collection_concatenation_with_duplicate_():
headers = Headers([(b"Hello", b"World"), (b"Svil", b"Power")])
headers += (b"Svil", b"Kitty")
example = headers[b"Svil"]
assert len(example) == | 2 | assert | numeric_literal | tests/test_headers.py | test_iadd_http_header_collection_concatenation_with_duplicate_ | 227 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep import Request, Response
from blacksheep.contents import TextContent
from blacksheep.server.remotes.scheme import (
HTTPSchemeMiddleware,
configure_scheme_middleware,
)
from blacksheep.server.security.hsts import HSTSMiddleware
from blacksheep.testing.helpers import get_example_sc... | 1 | assert | numeric_literal | tests/test_scheme.py | test_force_https_enables_https_and_hsts | TestConfigureSchemeMiddleware | 78 | null |
Neoteroi/BlackSheep | from datetime import timedelta
import pytest
from blacksheep import URL, Cookie, Response, TextContent
from blacksheep.client import ClientSession
from blacksheep.client.cookies import (
CookieJar,
InvalidCookieDomain,
MissingSchemeInURL,
StoredCookie,
)
from blacksheep.cookies import datetime_from_co... | 1 | assert | numeric_literal | tests/client/test_cookiejar.py | test_get_cookies_for_url | 396 | null | |
Neoteroi/BlackSheep | from io import BytesIO
from pathlib import Path
import pytest
from blacksheep.contents import MultiPartFormData
from blacksheep.multipart import (
FormPart,
_remove_last_crlf,
parse_multipart,
parse_multipart_async,
parse_part,
)
from .examples.multipart import (
FIELDS_THREE_VALUES,
FIEL... | "title" | assert | string_literal | tests/test_multipart.py | test_multipart_write_multiple_files | 230 | null | |
Neoteroi/BlackSheep | from blacksheep.url import URL
from perf.benchmarks import main_run, sync_benchmark
ITERATIONS = 10000
def test_url_instantiate():
url = URL(b"https://www.neoteroi.dev/blacksheep/?super=yes#some-hash")
assert url.value == b"https://www.neoteroi.dev/blacksheep/?super=yes#some-hash"
assert url.host == b"www... | b"https" | assert | string_literal | perf/benchmarks/url.py | test_url_instantiate | 19 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep import URL, Request, Response
from blacksheep.client import ClientSession
from blacksheep.client.connection import ConnectionClosedError
from blacksheep.client.exceptions import UnsupportedRedirect
from blacksheep.client.session import normalize_headers
from blacksheep.contents import Tex... | result | assert | variable | tests/client/test_client.py | test_get_url_value | 23 | null | |
Neoteroi/BlackSheep | from dataclasses import dataclass
from functools import wraps
from typing import Annotated, ClassVar, Generic, TypeVar
import pytest
from guardpost import AuthenticationHandler, User
from pydantic import Field
from rodi import inject
from blacksheep.messages import Request, Response
from blacksheep.server.application... | j | assert | variable | tests/test_controllers.py | test_controller_supports_on_request | 333 | null | |
Neoteroi/BlackSheep | from io import BytesIO
from pathlib import Path
import pytest
from blacksheep.contents import MultiPartFormData
from blacksheep.multipart import (
FormPart,
_remove_last_crlf,
parse_multipart,
parse_multipart_async,
parse_part,
)
from .examples.multipart import (
FIELDS_THREE_VALUES,
FIEL... | 4 | assert | numeric_literal | tests/test_multipart.py | test_multipart_write_only_fields | 280 | null | |
Neoteroi/BlackSheep | from pydantic import BaseModel
from blacksheep.server.bindings import FromJSON
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages import MockReceive, MockSend
async def _post_scenario(app, request_body):
await app(
get_example_scope(
"POST",
"... | None | assert | none_literal | tests/test_application2.py | home | 61 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.server.openapi.common import ParameterInfo
from blacksheep.server.openapi.docstrings import (
DocstringInfo,
EpytextDialect,
GoogleDocDialect,
NumpydocDialect,
ReStructuredTextDialect,
collapse,
)
@pytest.mark.parametrize(
"docstring,expected_info,match",
... | match | assert | variable | tests/test_openapi_docstrings.py | test_epytext_dialect | 243 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from datetime import datetime
from typing import Any, List, Literal, Sequence, Set, Tuple, Type
from uuid import UUID
import pytest
from guardpost import Identity
from pydantic import BaseModel
from pytest import raises
from rodi import Container
from blacksheep import For... | None | assert | none_literal | tests/test_bindings.py | test_from_body_json_binding_request_missing_content_type | 318 | null | |
Neoteroi/BlackSheep | from datetime import datetime
import pytest
from blacksheep import (
Cookie,
CookieSameSiteMode,
datetime_from_cookie_format,
datetime_to_cookie_format,
parse_cookie,
scribe,
)
from blacksheep.cookies import CookieValueExceedsMaximumLength
COOKIES = [
(
"Foo",
"Power",
... | None | assert | none_literal | tests/test_cookies.py | test_parse_cookie | 176 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from datetime import datetime
from typing import Any, List, Literal, Sequence, Set, Tuple, Type
from uuid import UUID
import pytest
from guardpost import Identity
from pydantic import BaseModel
from pytest import raises
from rodi import Container
from blacksheep import For... | 3 | assert | numeric_literal | tests/test_bindings.py | test_from_body_json_binding_collections | 1,073 | null | |
Neoteroi/BlackSheep | import os
from unittest.mock import patch
import pytest
from essentials.secrets import Secret
from itsdangerous import BadSignature
from blacksheep.server.dataprotection import generate_secret, get_keys, get_serializer
def get_secrets() -> list[Secret]:
"""
Retrieve application secret keys as Secret objects.... | get_keys() | assert | func_call | tests/test_dataprotection.py | test_get_keys_creates_default_keys | 33 | null | |
Neoteroi/BlackSheep | import base64
import pytest
from essentials.secrets import Secret
from guardpost import Identity
from blacksheep.server.authentication.basic import (
BasicAuthentication,
BasicCredentials,
BasicCredentialsProvider,
)
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages... | [] | assert | collection | tests/test_auth_basic.py | test_basic_credentials_defaults | 73 | null | |
Neoteroi/BlackSheep | from dataclasses import dataclass
from blacksheep.server.responses import ok
from blacksheep.server.routing import Router
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages import MockReceive, MockSend
from tests.utils.application import FakeApplication
async def test_applicatio... | text | assert | variable | tests/test_encodings.py | test_application_encoding_error_1 | 43 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.server.controllers import Controller
from blacksheep.server.headers.cache import (
CacheControlMiddleware,
cache_control,
write_cache_control_response_header,
)
from blacksheep.server.routing import RoutesRegistry
from blacksheep.testing.helpers import get_example_scope
from b... | ValueError) | pytest.raises | variable | tests/test_caching.py | test_write_cache_control_response_header_raises_for_priv_pub | 87 | null | |
Neoteroi/BlackSheep | import time
import pytest
from blacksheep.cookies import parse_cookie
from blacksheep.messages import Request
from blacksheep.server.responses import text
from blacksheep.sessions import Session
from blacksheep.sessions.cookies import CookieSessionStore
from blacksheep.sessions.json import JSONSerializer
from blacksh... | 1 | assert | numeric_literal | tests/test_sessions.py | test_session_base_methods | 44 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from datetime import datetime
from typing import Any, List, Literal, Sequence, Set, Tuple, Type
from uuid import UUID
import pytest
from guardpost import Identity
from pydantic import BaseModel
from pytest import raises
from rodi import Container
from blacksheep import For... | 7 | assert | numeric_literal | tests/test_bindings.py | test_xml_binder_parses_simple_fields | 1,384 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.url import URL, InvalidURL, join_prefix
@pytest.mark.parametrize(
"value,expected_base_url",
[
[
b"https://robertoprevato.github.io/api/v1/cats",
b"https://robertoprevato.github.io",
],
[
b"https://robertoprevato.github.... | base_url.value | assert | complex_expr | tests/test_url.py | test_base_url | 116 | null | |
Neoteroi/BlackSheep | from datetime import datetime
import pytest
from blacksheep import (
Cookie,
CookieSameSiteMode,
datetime_from_cookie_format,
datetime_to_cookie_format,
parse_cookie,
scribe,
)
from blacksheep.cookies import CookieValueExceedsMaximumLength
COOKIES = [
(
"Foo",
"Power",
... | original.path | assert | complex_expr | tests/test_cookies.py | test_cookie_clone | 340 | null | |
Neoteroi/BlackSheep | from datetime import timedelta
import pytest
from blacksheep import URL, Cookie, Response, TextContent
from blacksheep.client import ClientSession
from blacksheep.client.cookies import (
CookieJar,
InvalidCookieDomain,
MissingSchemeInURL,
StoredCookie,
)
from blacksheep.cookies import datetime_from_co... | "world" | assert | string_literal | tests/client/test_cookiejar.py | test_get_cookies_for_url | 398 | null | |
Neoteroi/BlackSheep | import asyncio
import json
import os
import re
import sys
from base64 import urlsafe_b64decode, urlsafe_b64encode
from collections.abc import AsyncIterable
from dataclasses import dataclass
from datetime import date, datetime
from functools import wraps
from typing import Annotated, Any, Dict, Generic, List, TypeVar
fr... | 3 | assert | numeric_literal | tests/test_application.py | test_start_stop_multiple_events | 3,455 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.messages import Request
from blacksheep.server.application import Application
from blacksheep.server.routing import (
HostFilter,
InvalidValuePatternName,
MountRegistry,
Route,
RouteDuplicate,
RouteException,
RouteFilter,
RouteMethod,
RouteNotFound,
... | 3 | assert | numeric_literal | tests/test_router.py | test_router_iterable | 746 | null | |
Neoteroi/BlackSheep | from datetime import datetime
import pytest
from blacksheep import (
Cookie,
CookieSameSiteMode,
datetime_from_cookie_format,
datetime_to_cookie_format,
parse_cookie,
scribe,
)
from blacksheep.cookies import CookieValueExceedsMaximumLength
COOKIES = [
(
"Foo",
"Power",
... | "abc123" | assert | string_literal | tests/test_cookies.py | test_cookie_equality_with_string | 292 | null | |
Neoteroi/BlackSheep | import os
from unittest.mock import patch
import pytest
from essentials.secrets import Secret
from itsdangerous import BadSignature
from blacksheep.server.dataprotection import generate_secret, get_keys, get_serializer
def get_secrets() -> list[Secret]:
"""
Retrieve application secret keys as Secret objects.... | 3 | assert | numeric_literal | tests/test_dataprotection.py | test_get_keys_creates_default_keys | 31 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep import JSONContent, Request
from blacksheep.contents import (
FormPart,
HTMLContent,
MultiPartFormData,
StreamedContent,
TextContent,
parse_www_form,
write_www_form_urlencoded,
)
from blacksheep.multipart import (
get_boundary_from_header,
parse_content... | data | assert | variable | tests/test_contents.py | test_form_urlencoded_parser | 64 | null | |
Neoteroi/BlackSheep | import errno
import os
import socket
from contextlib import contextmanager
from pathlib import Path
from urllib.parse import urljoin
import requests
from .logs import get_logger
logger = get_logger()
def ensure_success(response):
if response.status_code != 200:
text = response.text
logger.error(... | chunk_two | assert | variable | itests/utils.py | assert_files_equals | 56 | null | |
Neoteroi/BlackSheep | import base64
import pytest
from essentials.secrets import Secret
from guardpost import Identity
from blacksheep.server.authentication.basic import (
BasicAuthentication,
BasicCredentials,
BasicCredentialsProvider,
)
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages... | {} | assert | collection | tests/test_auth_basic.py | test_basic_credentials_defaults | 72 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep import JSONContent, Request
from blacksheep.contents import (
FormPart,
HTMLContent,
MultiPartFormData,
StreamedContent,
TextContent,
parse_www_form,
write_www_form_urlencoded,
)
from blacksheep.multipart import (
get_boundary_from_header,
parse_content... | 5 | assert | numeric_literal | tests/test_contents.py | test_parse_multipart | 191 | null | |
Neoteroi/BlackSheep | import time
import pytest
from blacksheep.cookies import parse_cookie
from blacksheep.messages import Request
from blacksheep.server.responses import text
from blacksheep.sessions import Session
from blacksheep.sessions.cookies import CookieSessionStore
from blacksheep.sessions.json import JSONSerializer
from blacksh... | 3 | assert | numeric_literal | tests/test_sessions.py | test_session_base_methods | 46 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from datetime import date, datetime
from enum import IntEnum
from typing import Generic, Mapping, Sequence, TypeVar, Union
from uuid import UUID
import pytest
from openapidocs.common import Format, Serializer
from openapidocs.v3 import (
APIKeySecurity,
HTTPSecurity... | 2 | assert | numeric_literal | tests/test_openapi_v3.py | test_handles_forward_refs | 401 | null | |
Neoteroi/BlackSheep | import pytest
from openapidocs.v3 import Info, ValueFormat, ValueType
from blacksheep import Application, FileBuffer
from blacksheep.server.openapi.common import DefaultSerializer
from blacksheep.server.openapi.v3 import OpenAPIHandler
def get_test_app():
"""Create a test application."""
return Application()
... | yaml_text | assert | variable | tests/test_filedata_openapi_integration.py | test_filedata_yaml_output | 110 | null | |
Neoteroi/BlackSheep | from dataclasses import dataclass, field
import pytest
from blacksheep.contents import FileBuffer
from blacksheep.server.bindings import FromForm
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages import MockReceive, MockSend
from tests.utils.application import FakeApplication
... | [] | assert | collection | tests/test_file_buffer.py | upload_minimal_handler | 141 | null | |
Neoteroi/BlackSheep | from typing import Any
from essentials.secrets import Secret
from guardpost import Identity
from blacksheep.messages import Request, Response
from blacksheep.server.authentication.cookie import CookieAuthentication
from blacksheep.server.dataprotection import generate_secret
from blacksheep.utils.time import utcnow
... | True | assert | bool_literal | tests/test_auth_cookie.py | test_cookie_authentication | 44 | null | |
Neoteroi/BlackSheep | from dataclasses import dataclass
from functools import wraps
from typing import Annotated, ClassVar, Generic, TypeVar
import pytest
from guardpost import AuthenticationHandler, User
from pydantic import Field
from rodi import inject
from blacksheep.messages import Request, Response
from blacksheep.server.application... | 6 | assert | numeric_literal | tests/test_controllers.py | test_controllers_inheritance | 1,056 | null | |
Neoteroi/BlackSheep | from datetime import datetime
import pytest
from blacksheep import (
Cookie,
CookieSameSiteMode,
datetime_from_cookie_format,
datetime_to_cookie_format,
parse_cookie,
scribe,
)
from blacksheep.cookies import CookieValueExceedsMaximumLength
COOKIES = [
(
"Foo",
"Power",
... | name | assert | variable | tests/test_cookies.py | test_parse_cookie | 177 | null | |
Neoteroi/BlackSheep | from typing import Sequence
from urllib.parse import quote, urlencode
_DEFAULT_AGENT = (
b"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:63.0) Gecko/20100101 Firefox/63.0"
)
_DEFAULT_ACCEPT = b"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
_DEFAULT_ACCEPT_LANGUAGE = b"en-US,en;q=0.9,it-IT;q=0.8,i... | 2 | assert | numeric_literal | blacksheep/testing/helpers.py | _get_tuple | 18 | null | |
Neoteroi/BlackSheep | from asyncio import AbstractEventLoop
from datetime import datetime
from pathlib import Path
from unittest.mock import create_autospec
import pytest
from essentials.folders import get_file_extension
from blacksheep import Application, Request
from blacksheep.common.files.asyncfs import FileContext, FilesHandler
from ... | 1 | assert | numeric_literal | tests/test_files_serving.py | test_serve_files_index_html_options | 872 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.server.openapi.common import ParameterInfo
from blacksheep.server.openapi.docstrings import (
DocstringInfo,
EpytextDialect,
GoogleDocDialect,
NumpydocDialect,
ReStructuredTextDialect,
collapse,
)
@pytest.mark.parametrize(
"docstring,expected_info,match",
... | info | assert | variable | tests/test_openapi_docstrings.py | test_epytext_dialect | 246 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep import Header, Headers
def test_http_header_collection_item_setter():
headers = Headers()
example = headers.get(b"example")
assert example == | tuple() | assert | func_call | tests/test_headers.py | test_http_header_collection_item_setter | 59 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from inspect import Parameter, _ParameterKind
from typing import AsyncIterable, Sequence
import pytest
from guardpost import Identity, User
from pytest import raises
from rodi import Container, Services, inject
from blacksheep import Request
from blacksheep.server.bindings... | "c" | assert | string_literal | tests/test_normalization.py | test_parameters_get_binders_default_query | 68 | null | |
Neoteroi/BlackSheep | import re
import pytest
from blacksheep.contents import write_www_form_urlencoded
from blacksheep.messages import Response
from blacksheep.server.controllers import Controller
from blacksheep.server.csrf import ignore_anti_forgery, use_anti_forgery
from blacksheep.server.rendering.jinja2 import AntiForgeryBaseExtensi... | text | assert | variable | tests/test_csrf.py | _assert_generation_scenario | 43 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from datetime import date, datetime
from enum import IntEnum
from typing import Generic, Mapping, Sequence, TypeVar, Union
from uuid import UUID
import pytest
from openapidocs.common import Format, Serializer
from openapidocs.v3 import (
APIKeySecurity,
HTTPSecurity... | 3 | assert | numeric_literal | tests/test_openapi_v3.py | test_multi_format_union_body_generates_all_content_types | 4,741 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from inspect import Parameter, _ParameterKind
from typing import AsyncIterable, Sequence
import pytest
from guardpost import Identity, User
from pytest import raises
from rodi import Container, Services, inject
from blacksheep import Request
from blacksheep.server.bindings... | 1 | assert | numeric_literal | tests/test_normalization.py | test_parameters_get_binders_from_body | 125 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep import Header, Headers
def test_iadd_http_header_collection_concatenation_with_():
headers = Headers([(b"Hello", b"World"), (b"Svil", b"Power")])
headers += (b"Foo", b"foo")
example = headers[b"Foo"]
assert len(example) == 1
header = example[0]
assert header =... | b"foo" | assert | string_literal | tests/test_headers.py | test_iadd_http_header_collection_concatenation_with_ | 192 | null | |
Neoteroi/BlackSheep | import asyncio
import json
import os
import re
import sys
from base64 import urlsafe_b64decode, urlsafe_b64encode
from collections.abc import AsyncIterable
from dataclasses import dataclass
from datetime import date, datetime
from functools import wraps
from typing import Annotated, Any, Dict, Generic, List, TypeVar
fr... | 1 | assert | numeric_literal | tests/test_application.py | test_application_post_handler | 271 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from datetime import datetime
from io import BytesIO
from typing import Any, AsyncIterable, Callable
from uuid import UUID, uuid4
import pytest
from blacksheep import Content, Cookie, Response, scribe
from blacksheep.exceptions import FailedRequestError
from blacksheep.ser... | foo | assert | variable | tests/test_responses.py | test_response_supports_dynamic_attributes | 140 | null | |
Neoteroi/BlackSheep | import json
import re
from datetime import datetime
from typing import Any
from unittest.mock import AsyncMock
from urllib.parse import parse_qs, urlencode
import pytest
from essentials.secrets import Secret
from guardpost import Identity, Policy
from guardpost.common import AuthenticatedRequirement
from blacksheep.c... | 3 | assert | numeric_literal | itests/test_auth_oidc.py | test_oidc_handler_auth_post_id_token_code_3 | 1,069 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.contents import ServerSentEvent
from blacksheep.server.sse import ServerSentEventsResponse
@pytest.mark.asyncio
async def test_server_sent_events_response_streams_events_1():
# Arrange: create a simple events provider
async def events_provider():
yield ServerSentEvent(dat... | result | assert | variable | tests/test_sse.py | test_server_sent_events_response_streams_events_1 | 22 | null | |
Neoteroi/BlackSheep | import base64
import pytest
from essentials.secrets import Secret
from guardpost import Identity
from blacksheep.server.authentication.basic import (
BasicAuthentication,
BasicCredentials,
BasicCredentialsProvider,
)
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages... | None | assert | none_literal | tests/test_auth_basic.py | test_basic_authentication_success | 177 | null | |
Neoteroi/BlackSheep | import asyncio
import os
import pathlib
import shutil
from uuid import uuid4
import pytest
from blacksheep.common.files.asyncfs import FileContext, FilesHandler
def files_folder():
return pathlib.Path(__file__).parent.absolute() / "files"
def temp_files_folder():
temp_folder = pathlib.Path(__file__).parent.... | TypeError) | pytest.raises | variable | tests/test_files_handler.py | test_file_context_raises_if_file_is_not_open | 186 | null | |
Neoteroi/BlackSheep | import re
import pytest
from blacksheep.contents import write_www_form_urlencoded
from blacksheep.messages import Response
from blacksheep.server.controllers import Controller
from blacksheep.server.csrf import ignore_anti_forgery, use_anti_forgery
from blacksheep.server.rendering.jinja2 import AntiForgeryBaseExtensi... | 2 | assert | numeric_literal | tests/test_csrf.py | test_anti_forgery_token_generation_multiple | 114 | null | |
Neoteroi/BlackSheep | from io import BytesIO
from pathlib import Path
import pytest
from blacksheep.contents import MultiPartFormData
from blacksheep.multipart import (
FormPart,
_remove_last_crlf,
parse_multipart,
parse_multipart_async,
parse_part,
)
from .examples.multipart import (
FIELDS_THREE_VALUES,
FIEL... | "file3" | assert | string_literal | tests/test_multipart.py | test_multipart_write_multiple_files | 239 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from datetime import datetime
from typing import Any, List, Literal, Sequence, Set, Tuple, Type
from uuid import UUID
import pytest
from guardpost import Identity
from pydantic import BaseModel
from pytest import raises
from rodi import Container
from blacksheep import For... | "1" | assert | string_literal | tests/test_bindings.py | test_element_to_dict_handles_nested | 1,474 | null | |
Neoteroi/BlackSheep | import asyncio
import os
import pathlib
import shutil
from uuid import uuid4
import pytest
from blacksheep.common.files.asyncfs import FileContext, FilesHandler
def files_folder():
return pathlib.Path(__file__).parent.absolute() / "files"
def temp_files_folder():
temp_folder = pathlib.Path(__file__).parent.... | chunk_read | assert | variable | tests/test_files_handler.py | test_seek_and_read_chunk | 95 | null | |
Neoteroi/BlackSheep | from datetime import timedelta
import pytest
from blacksheep import URL, Cookie, Response, TextContent
from blacksheep.client import ClientSession
from blacksheep.client.cookies import (
CookieJar,
InvalidCookieDomain,
MissingSchemeInURL,
StoredCookie,
)
from blacksheep.cookies import datetime_from_co... | "world2" | assert | string_literal | tests/client/test_cookiejar.py | test_cookie_jar_does_not_override_http_only_cookie_with_non_http_only_cookie | 522 | null | |
Neoteroi/BlackSheep | import os
import shutil
from typing import AsyncIterable, Callable
from uuid import uuid4
import pytest
from blacksheep import (
FormContent,
FormPart,
JSONContent,
MultiPartFormData,
Response,
StreamedContent,
)
from blacksheep.common.files.asyncfs import FilesHandler
from .client_fixtures i... | 0 | assert | numeric_literal | itests/test_client.py | test_response_body_streaming_large_file | 342 | null | |
Neoteroi/BlackSheep | import base64
import pytest
from essentials.secrets import Secret
from guardpost import Identity
from blacksheep.server.authentication.basic import (
BasicAuthentication,
BasicCredentials,
BasicCredentialsProvider,
)
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages... | True | assert | bool_literal | tests/test_auth_basic.py | test_basic_credentials_match_success | 94 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.messages import Request
from blacksheep.server.application import Application
from blacksheep.server.routing import (
HostFilter,
InvalidValuePatternName,
MountRegistry,
Route,
RouteDuplicate,
RouteException,
RouteFilter,
RouteMethod,
RouteNotFound,
... | c | assert | variable | tests/test_router.py | test_router_match_any_below | 382 | null | |
Neoteroi/BlackSheep | import sys
from dataclasses import dataclass
from inspect import Parameter, _ParameterKind
from typing import AsyncIterable, Sequence
import pytest
from guardpost import Identity, User
from pytest import raises
from rodi import Container, Services, inject
from blacksheep import Request
from blacksheep.server.bindings... | int | assert | variable | tests/test_normalization.py | test_parameters_get_binders_from_services_by_type | 117 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.ranges import InvalidRangeValue, Range, RangePart
@pytest.mark.parametrize(
"range_a,range_b,equals",
[
[
Range("bytes", [RangePart(100, None)]),
Range("bytes", [RangePart(100, None)]),
True,
],
[
Range("byte... | equals | assert | variable | tests/test_ranges.py | test_range_equality | 41 | null | |
Neoteroi/BlackSheep | import time
import pytest
from blacksheep.cookies import parse_cookie
from blacksheep.messages import Request
from blacksheep.server.responses import text
from blacksheep.sessions import Session
from blacksheep.sessions.cookies import CookieSessionStore
from blacksheep.sessions.json import JSONSerializer
from blacksh... | True | assert | bool_literal | tests/test_sessions.py | test_session_modified | 131 | null | |
Neoteroi/BlackSheep | from dataclasses import dataclass
import pytest
from pydantic import BaseModel
from blacksheep.server.controllers import Controller, RoutesRegistry
from blacksheep.server.rendering.jinja2 import get_template_name
from blacksheep.server.responses import view, view_async
from blacksheep.settings.html import html_settin... | 2 | assert | numeric_literal | tests/test_templating.py | test_model_to_view_params_passes_unhandled_argument | 386 | null | |
Neoteroi/BlackSheep | import pytest
from blacksheep.messages import Response
from blacksheep.middlewares import (
CategorizedMiddleware,
MiddlewareCategory,
MiddlewareList,
)
async def middleware_a() -> Response: ...
async def middleware_b() -> Response: ...
async def middleware_c() -> Response: ...
async def middleware_d()... | 3 | assert | numeric_literal | tests/test_middlewares.py | test_extend | TestMiddlewareList | 76 | null |
Neoteroi/BlackSheep | import pytest
from essentials.secrets import Secret
from guardpost import Identity
from blacksheep.server.authentication.apikey import (
APIKey,
APIKeyAuthentication,
APIKeyLocation,
APIKeysProvider,
)
from blacksheep.testing.helpers import get_example_scope
from blacksheep.testing.messages import Mock... | {} | assert | collection | tests/test_auth_api_key.py | test_api_key_defaults | 63 | null | |
Neoteroi/BlackSheep | from uuid import uuid4
import pytest
from blacksheep.utils.aio import (
FailedRequestError,
HTTPHandler,
_try_parse_content_as_json,
)
def test_try_parse_content_as_json():
assert _try_parse_content_as_json(b"foo") == | b"foo" | assert | string_literal | itests/test_utils_aio.py | test_try_parse_content_as_json | 58 | null | |
hyprland-community/pyprland | import os
from pathlib import Path
from unittest.mock import AsyncMock, Mock, patch
import pytest
from pyprland.plugins.wallpapers.cache import ImageCache
from pyprland.plugins.wallpapers.imageutils import (
IMAGE_FORMAT,
MonitorInfo,
RoundedImageManager,
expand_path,
get_effective_dimensions,
... | "#ff0000" | assert | string_literal | tests/test_wallpapers_imageutils.py | test_color_conversions | 77 | null | |
hyprland-community/pyprland | import pytest
import tomllib
from pytest_asyncio import fixture
from .conftest import mocks as tst
from .testtools import wait_called
async def shapeL_config(monkeypatch):
"""L shape."""
config = """
[pyprland]
plugins = ["monitors"]
[monitors]
startup_relayout = false
new_monitor_delay = 0
[monitors.placem... | "notify" | assert | string_literal | tests/test_plugin_monitor.py | test_nothing | 326 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import Mock, AsyncMock, patch
from pyprland.plugins.interface import Plugin
from pyprland.config import Configuration
def plugin():
plugin = ConcretePlugin("test_plugin")
# Manually attach mocks for methods used in get_clients
plugin.hyprctl_json = AsyncMock()
plugin.st... | "value1" | assert | string_literal | tests/test_interface.py | test_load_config | 46 | null | |
hyprland-community/pyprland | import pytest
from pyprland.common import merge, apply_filter, is_rotated
def test_is_rotated():
assert is_rotated({"transform": 1}) is True
assert is_rotated({"transform": 3}) is True
assert is_rotated({"transform": 5}) is True
assert is_rotated({"transform": 7}) is True
assert is_rotated({"tran... | False | assert | bool_literal | tests/test_common_utils.py | test_is_rotated | 52 | null | |
hyprland-community/pyprland | from typing import cast
from unittest.mock import AsyncMock, Mock
import pytest
import tomllib
from .conftest import mocks as tst
from .testtools import wait_called
from pyprland.manager import Pyprland
@pytest.mark.usefixtures("sample1_config", "server_fixture")
@pytest.mark.asyncio
async def test_reload(monkeypat... | True | assert | bool_literal | tests/test_pyprland.py | test_reload | 44 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import Mock, AsyncMock, patch
from pyprland.plugins.interface import Plugin
from pyprland.config import Configuration
def plugin():
plugin = ConcretePlugin("test_plugin")
# Manually attach mocks for methods used in get_clients
plugin.hyprctl_json = AsyncMock()
plugin.st... | 4 | assert | numeric_literal | tests/test_interface.py | test_get_clients_filter | 92 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import Mock, AsyncMock, patch
from pyprland.plugins.interface import Plugin
from pyprland.config import Configuration
def plugin():
plugin = ConcretePlugin("test_plugin")
# Manually attach mocks for methods used in get_clients
plugin.hyprctl_json = AsyncMock()
plugin.st... | "1") | assert_* | string_literal | tests/test_interface.py | test_get_clients_filter | 102 | null | |
hyprland-community/pyprland | import pytest
from pyprland.common import merge, apply_filter, is_rotated
def test_apply_filter_empty():
assert apply_filter("hello", "") == | "hello" | assert | string_literal | tests/test_common_utils.py | test_apply_filter_empty | 27 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import AsyncMock
from pyprland.plugins.toggle_dpms import Extension
from tests.conftest import make_extension
def extension():
ext = make_extension(Extension)
# Mocking monitor list
ext.backend.get_monitors = AsyncMock(return_value=[{"name": "DP-1", "dpmsStatus": True}, {"... | "dpms on") | assert_* | string_literal | tests/test_plugin_toggle_dpms.py | test_run_toggle_dpms_on | 36 | null | |
hyprland-community/pyprland | import asyncio
import json
import logging
import pytest
from unittest.mock import Mock, AsyncMock, patch
from pyprland import ipc
from pyprland.models import PyprError
from pyprland.adapters.hyprland import HyprlandBackend
def mock_open_connection(mocker):
reader = AsyncMock()
# StreamWriter methods write and ... | {"status": "ok"} | assert | collection | tests/test_ipc.py | test_get_response | 66 | null | |
hyprland-community/pyprland | import pytest
import pytest_asyncio
import asyncio
from unittest.mock import Mock, AsyncMock, patch
from pyprland.plugins.system_notifier import Extension, builtin_parsers
from tests.conftest import make_extension
async def extension():
ext = make_extension(
Extension,
config={"parsers": {}, "sourc... | "Match me" | assert | string_literal | tests/test_plugin_system_notifier.py | test_notify_send_option | 101 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import Mock, patch, AsyncMock, MagicMock
import asyncio
import sys
import os
import tempfile
from pathlib import Path
from pyprland.command import Pyprland
from pyprland.models import ExitCode, PyprError
from pyprland.validate_cli import run_validate, _load_plugin_module
def pyprland_a... | mock_toml | assert | variable | tests/test_command.py | test_load_config_toml | 51 | null | |
hyprland-community/pyprland | import pytest
import math
from unittest.mock import Mock, patch, MagicMock
from pyprland.plugins.wallpapers.colorutils import (
_build_hue_histogram,
_smooth_histogram,
_find_peaks,
_get_best_pixel_for_hue,
_calculate_hue_diff,
_select_colors_from_peaks,
get_dominant_colors,
nicify_oklab... | {} | assert | collection | tests/test_wallpapers_colors.py | test_color_scheme_props_default | 275 | null | |
hyprland-community/pyprland | import os
from pathlib import Path
from unittest.mock import AsyncMock, Mock, patch
import pytest
from pyprland.plugins.wallpapers.cache import ImageCache
from pyprland.plugins.wallpapers.imageutils import (
IMAGE_FORMAT,
MonitorInfo,
RoundedImageManager,
expand_path,
get_effective_dimensions,
... | 1 | assert | numeric_literal | tests/test_wallpapers_imageutils.py | test_get_files_with_ext | 64 | null | |
hyprland-community/pyprland | from pathlib import Path
import pytest
from unittest.mock import Mock, AsyncMock, patch
from pyprland.plugins.menubar import get_pid_from_layers_hyprland, is_bar_in_layers_niri, is_bar_alive, Extension
from tests.conftest import make_extension
@pytest.mark.asyncio
async def test_is_bar_alive_niri():
backend = Moc... | "Layers") | assert_* | string_literal | tests/test_plugin_menubar.py | test_is_bar_alive_niri | 92 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import AsyncMock
from pyprland.plugins.layout_center import Extension
from tests.conftest import make_extension
def extension():
return make_extension(
Extension,
state_active_window="0x1",
config={"margin": 50, "offset": "10 20"},
notify_error=Async... | True | assert | bool_literal | tests/test_plugin_layout_center.py | test_sanity_check_passes | 32 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import Mock, call
from pyprland.plugins.shift_monitors import Extension
from tests.conftest import make_extension
def extension():
ext = make_extension(Extension)
ext.monitors = ["M1", "M2", "M3"]
ext.state.environment = "hyprland" # Default to hyprland for existing tests... | 2 | assert | numeric_literal | tests/test_plugin_shift_monitors.py | test_shift_positive | 33 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import Mock, AsyncMock, patch
from pyprland.plugins.interface import Plugin
from pyprland.config import Configuration
def plugin():
plugin = ConcretePlugin("test_plugin")
# Manually attach mocks for methods used in get_clients
plugin.hyprctl_json = AsyncMock()
plugin.st... | plugin.config | assert | complex_expr | tests/test_interface.py | test_load_config | 48 | null | |
hyprland-community/pyprland | from __future__ import annotations
import json
import shutil
import subprocess
from pathlib import Path
import pytest
from pyprland.commands.models import CommandArg, CommandInfo
from pyprland.commands.tree import build_command_tree
from pyprland.completions.discovery import _build_command_from_node, _classify_arg
f... | 0 | assert | numeric_literal | tests/test_completions.py | test_syntax_valid | TestZshSyntax | 137 | null |
hyprland-community/pyprland | from pathlib import Path
import pytest
from unittest.mock import Mock, AsyncMock, patch
from pyprland.plugins.menubar import get_pid_from_layers_hyprland, is_bar_in_layers_niri, is_bar_alive, Extension
from tests.conftest import make_extension
def test_is_bar_in_layers_niri():
# Bar exists
layers = [
... | True | assert | bool_literal | tests/test_plugin_menubar.py | test_is_bar_in_layers_niri | 42 | null | |
hyprland-community/pyprland | import asyncio
import pytest
from pytest_asyncio import fixture
from .conftest import mocks
from .testtools import wait_called
def scratchpads(monkeypatch, mocker):
d = {
"pyprland": {"plugins": ["scratchpads"]},
"scratchpads": {
"term": {
"command": "ls",
... | starts[1] | assert | complex_expr | tests/test_plugin_scratchpads.py | test_command_serialization | 445 | null | |
hyprland-community/pyprland | import logging
import pytest
from pyprland.adapters.wayland import WaylandBackend
from pyprland.adapters.xorg import XorgBackend
from pyprland.common import SharedState
def mock_state():
"""Provide a mock SharedState for tests."""
return SharedState()
class TestWaylandBackend:
def test_parse_multiple_mon... | 2 | assert | numeric_literal | tests/test_adapters_fallback.py | test_parse_multiple_monitors | TestWaylandBackend | 74 | null |
hyprland-community/pyprland | import pytest
from pyprland.plugins.monitors.layout import (
MAX_CYCLE_PATH_LENGTH,
MONITOR_PROPS,
build_graph,
compute_positions,
compute_xy,
find_cycle_path,
get_dims,
)
def make_monitor(name, width=1920, height=1080, x=0, y=0, scale=1.0, transform=0):
"""Helper to create a monitor d... | 1 | assert | numeric_literal | tests/test_monitors_layout.py | test_basic_graph | TestBuildGraph | 221 | null |
hyprland-community/pyprland | from pyprland.config import Configuration
from pyprland.validation import ConfigField, ConfigValidator, _find_similar_key, format_config_error
def test_config_validator_type_checking(test_logger):
"""Test type validation."""
schema = [
ConfigField("count", int),
ConfigField("factor", float),
... | 6 | assert | numeric_literal | tests/test_config.py | test_config_validator_type_checking | 214 | null | |
hyprland-community/pyprland | import pytest
from pyprland.plugins.lost_windows import Extension, contains
from tests.conftest import make_extension
def extension():
return make_extension(Extension)
def test_contains():
monitor = {"x": 0, "y": 0, "width": 1920, "height": 1080}
# Inside
assert contains(monitor, {"at": [100, 100]})... | True | assert | bool_literal | tests/test_plugin_lost_windows.py | test_contains | 15 | null | |
hyprland-community/pyprland | from pyprland.config import Configuration
from pyprland.validation import ConfigField, ConfigValidator, _find_similar_key, format_config_error
def test_config_access(test_logger):
conf = Configuration({"a": 1, "b": "test"}, logger=test_logger)
assert conf["a"] == | 1 | assert | numeric_literal | tests/test_config.py | test_config_access | 7 | null | |
hyprland-community/pyprland | import pytest
import math
from unittest.mock import Mock, patch, MagicMock
from pyprland.plugins.wallpapers.colorutils import (
_build_hue_histogram,
_smooth_histogram,
_find_peaks,
_get_best_pixel_for_hue,
_calculate_hue_diff,
_select_colors_from_peaks,
get_dominant_colors,
nicify_oklab... | [0] | assert | collection | tests/test_wallpapers_colors.py | test_build_hue_histogram | 48 | null | |
hyprland-community/pyprland | import os
from pathlib import Path
from unittest.mock import AsyncMock, Mock, patch
import pytest
from pyprland.plugins.wallpapers.cache import ImageCache
from pyprland.plugins.wallpapers.imageutils import (
IMAGE_FORMAT,
MonitorInfo,
RoundedImageManager,
expand_path,
get_effective_dimensions,
... | (1920, 1080) | assert | collection | tests/test_wallpapers_imageutils.py | test_get_effective_dimensions_no_rotation | 130 | null | |
hyprland-community/pyprland | import asyncio
import json
import logging
import pytest
from unittest.mock import Mock, AsyncMock, patch
from pyprland import ipc
from pyprland.models import PyprError
from pyprland.adapters.hyprland import HyprlandBackend
def mock_open_connection(mocker):
reader = AsyncMock()
# StreamWriter methods write and ... | None | assert | none_literal | tests/test_ipc.py | test_backend_get_client_props | 139 | null | |
hyprland-community/pyprland | import asyncio
import pytest
from pyprland.process import ManagedProcess, SupervisedProcess
class TestManagedProcess:
@pytest.mark.asyncio
async def test_process_property(self):
"""Test accessing underlying process."""
proc = ManagedProcess()
assert proc.process is None
awai... | proc.pid | assert | complex_expr | tests/test_process.py | test_process_property | TestManagedProcess | 156 | null |
hyprland-community/pyprland | from pyprland.config import Configuration
from pyprland.validation import ConfigField, ConfigValidator, _find_similar_key, format_config_error
def test_config_validator_required_fields(test_logger):
"""Test validation of required fields."""
schema = [
ConfigField("command", str, required=True),
... | 0 | assert | numeric_literal | tests/test_config.py | test_config_validator_required_fields | 175 | null | |
hyprland-community/pyprland | import pytest
from pyprland.commands.discovery import extract_commands_from_object, get_client_commands
from pyprland.commands.models import CommandArg, CommandInfo
from pyprland.commands.parsing import parse_docstring
class TestParseDocstring:
def test_required_arg(self):
"""Test parsing a required argu... | True | assert | bool_literal | tests/test_command_registry.py | test_required_arg | TestParseDocstring | 18 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.