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 |
|---|---|---|---|---|---|---|---|---|---|
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_build_hue_histogram | 52 | 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,
... | key | assert | variable | tests/test_wallpapers_imageutils.py | test_rounded_image_manager_paths | 109 | null | |
hyprland-community/pyprland | import os
from io import StringIO
from unittest.mock import patch
from pyprland.ansi import (
BOLD,
DIM,
RED,
RESET,
YELLOW,
HandlerStyles,
LogStyles,
colorize,
make_style,
should_colorize,
)
def test_constants():
"""Test that ANSI constants have expected values."""
ass... | "2" | assert | string_literal | tests/test_ansi.py | test_constants | 91 | 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",
... | [] | assert | collection | tests/test_plugin_scratchpads.py | test_excluded_scratches_isolation | 377 | null | |
hyprland-community/pyprland | import os
import time
import pytest
from pyprland.plugins.wallpapers.cache import ImageCache
def test_cache_cleanup_with_ttl(tmp_path):
"""cleanup() removes files older than TTL."""
cache = ImageCache(cache_dir=tmp_path, ttl=1)
old_file = tmp_path / "old.jpg"
new_file = tmp_path / "new.jpg"
old_... | 1 | assert | numeric_literal | tests/test_wallpapers_cache.py | test_cache_cleanup_with_ttl | 117 | null | |
hyprland-community/pyprland | import asyncio
from pathlib import Path
from unittest.mock import AsyncMock, Mock, patch
import pytest
from pyprland.plugins.wallpapers import Extension, OnlineState
from pyprland.plugins.wallpapers.models import Theme
from pyprland.plugins.wallpapers.online import OnlineFetcher
from tests.conftest import make_extens... | 4 | assert | numeric_literal | tests/test_plugin_wallpapers.py | test_prefetch_online_image_retry | 333 | null | |
hyprland-community/pyprland | import pytest
from pyprland.plugins.monitors.commands import (
NIRI_TRANSFORM_NAMES,
build_hyprland_command,
build_niri_disable_action,
build_niri_position_action,
build_niri_scale_action,
build_niri_transform_action,
)
class TestNiriTransformNames:
def test_values(self):
"""Test ... | "180" | assert | string_literal | tests/test_monitors_commands.py | test_values | TestNiriTransformNames | 231 | null |
hyprland-community/pyprland | from pyprland.models import VersionInfo
def test_version_info_init():
v = VersionInfo(1, 2, 3)
assert v.major == 1
assert v.minor == | 2 | assert | numeric_literal | tests/test_common_types.py | test_version_info_init | 7 | 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,
... | expanded | assert | variable | tests/test_wallpapers_imageutils.py | test_expand_path | 25 | 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_single_monit... | 0 | assert | numeric_literal | tests/test_adapters_fallback.py | test_parse_single_monitor | TestWaylandBackend | 47 | null |
hyprland-community/pyprland | import os
from io import StringIO
from unittest.mock import patch
from pyprland.ansi import (
BOLD,
DIM,
RED,
RESET,
YELLOW,
HandlerStyles,
LogStyles,
colorize,
make_style,
should_colorize,
)
def test_log_styles():
"""Test LogStyles contains expected style tuples."""
a... | (YELLOW, DIM) | assert | collection | tests/test_ansi.py | test_log_styles | 76 | null | |
hyprland-community/pyprland | import os
from io import StringIO
from unittest.mock import patch
from pyprland.ansi import (
BOLD,
DIM,
RED,
RESET,
YELLOW,
HandlerStyles,
LogStyles,
colorize,
make_style,
should_colorize,
)
def test_make_style():
"""Test make_style returns correct prefix and suffix."""
... | "\x1b[33;2m" | assert | string_literal | tests/test_ansi.py | test_make_style | 42 | 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)
@pytest.mark.asyncio
async def test_run_attract_lost(extension):
monitor = {"id": 1, "name": "DP-1", "width": 1920, "height": 1080, "x": 0, "y... | calls[1] | assert | complex_expr | tests/test_plugin_lost_windows.py | test_run_attract_lost | 50 | 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 | numeric_literal | tests/test_interface.py | test_get_clients_filter | 97 | 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... | "arg1") | assert_* | string_literal | tests/test_command.py | test_run_plugin_handler_success | 139 | 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... | "" | assert | string_literal | tests/test_command.py | test_call_handler_dispatch | 190 | 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)
@pytest.mark.asyncio
async def test_run_attract_lost(extension):
monitor = {"id": 1, "name": "DP-1", "width": 1920, "height": 1080, "x": 0, "y... | calls[0] | assert | complex_expr | tests/test_plugin_lost_windows.py | test_run_attract_lost | 49 | 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,
... | "#00ff00" | assert | string_literal | tests/test_wallpapers_imageutils.py | test_color_conversions | 78 | 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... | 1 | assert | numeric_literal | tests/test_command.py | test_call_handler_dispatch | 192 | null | |
hyprland-community/pyprland | import os
import time
import pytest
from pyprland.plugins.wallpapers.cache import ImageCache
def test_cache_is_valid_no_ttl(tmp_path):
"""is_valid() returns True for existing files when no TTL."""
cache = ImageCache(cache_dir=tmp_path)
path = tmp_path / "test.jpg"
path.write_bytes(b"data")
asser... | True | assert | bool_literal | tests/test_wallpapers_cache.py | test_cache_is_valid_no_ttl | 33 | null | |
hyprland-community/pyprland | import asyncio
from pathlib import Path
from unittest.mock import AsyncMock, Mock, patch
import pytest
from pyprland.plugins.wallpapers import Extension, OnlineState
from pyprland.plugins.wallpapers.models import Theme
from pyprland.plugins.wallpapers.online import OnlineFetcher
from tests.conftest import make_extens... | parsed | assert | variable | tests/test_plugin_wallpapers.py | test_run_palette_json | 159 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import AsyncMock
from pyprland.plugins.shortcuts_menu import Extension
from pyprland.config import Configuration
from tests.conftest import make_extension
def extension(test_logger):
return make_extension(
Extension,
logger=test_logger,
config={
... | options | assert | variable | tests/test_plugin_shortcuts_menu.py | test_run_menu_formatting | 114 | 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,
... | (1080, 1920) | assert | collection | tests/test_wallpapers_imageutils.py | test_get_effective_dimensions_rotated | 138 | null | |
hyprland-community/pyprland | from pyprland.models import VersionInfo
def test_version_info_equality():
v1 = VersionInfo(1, 2, 3)
v2 = VersionInfo(1, 2, 3)
v3 = VersionInfo(1, 2, 4)
assert v1 == v2
assert v1 != | v3 | assert | variable | tests/test_common_types.py | test_version_info_equality | 44 | 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... | 20 | assert | numeric_literal | tests/test_monitors_layout.py | test_max_cycle_path_length | TestConstants | 392 | 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... | 0 | assert | numeric_literal | tests/test_plugin_monitor.py | assert_modes | 135 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import Mock
from pyprland.plugins.expose import Extension
from tests.conftest import make_extension
def sample_clients():
return [
{"address": "0x1", "workspace": {"id": 1, "name": "1"}, "class": "App1"},
{"address": "0x2", "workspace": {"id": 2, "name": "2"}, "clas... | calls | assert | variable | tests/test_plugin_expose.py | test_run_expose_enable | 57 | null | |
hyprland-community/pyprland | import pytest
from unittest.mock import AsyncMock
from pyprland.plugins.fetch_client_menu import Extension
from tests.conftest import make_extension
def extension():
ext = make_extension(
Extension,
config={"separator": "|", "center_on_fetch": True, "margin": 60},
menu=AsyncMock(),
... | "2") | assert_* | string_literal | tests/test_plugin_fetch_client_menu.py | test_run_unfetch_client_success | 28 | null | |
pydantic/pydantic-core | import dataclasses
import re
from collections import namedtuple
from functools import partial
import pytest
from pydantic_core import ArgsKwargs, SchemaValidator, ValidationError
from pydantic_core import core_schema as cs
from ..conftest import Err, PyAndJson, plain_repr
@pytest.mark.parametrize('input_value,expec... | plain_repr(v) | assert | func_call | tests/validators/test_call.py | test_function_return_any | 87 | null | |
pydantic/pydantic-core | import math
import re
import sys
from decimal import Decimal
from typing import Any
import pytest
from dirty_equals import FunctionCheck, IsFloatNan, IsStr
from pydantic_core import SchemaValidator, ValidationError, core_schema
from pydantic_core import core_schema as cs
from ..conftest import Err, PyAndJson, plain_... | IsFloatNan() | assert | func_call | tests/validators/test_float.py | test_allow_inf_nan_true_json | 411 | null | |
pydantic/pydantic-core | import pytest
from dirty_equals import IsStr
from pydantic_core import SchemaSerializer, core_schema
def gen_ok(*things):
yield from things
def gen_error(*things):
yield from things
raise ValueError('oops')
def test_any_iter():
s = SchemaSerializer(core_schema.any_schema())
gen = s.to_python(gen... | repr(gen) | assert | func_call | tests/serializers/test_generator.py | test_any_iter | 38 | null | |
pydantic/pydantic-core | import copy
import functools
import pickle
import sys
import unittest
from datetime import datetime, timedelta, timezone, tzinfo
from zoneinfo import ZoneInfo, ZoneInfoNotFoundError
from pydantic_core import SchemaValidator, TzInfo, core_schema
def first_sunday_on_or_after(dt):
days_to_go = 6 - dt.weekday()
i... | tz) | self.assertEqual | variable | tests/test_tzinfo.py | test_copy | TestTzInfo | 190 | null |
pydantic/pydantic-core | import re
import sys
from collections import defaultdict
from copy import deepcopy
from decimal import Decimal
from typing import Any, Callable, Union
import pytest
from dirty_equals import HasRepr, IsInstance
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, core_schema
from pydant... | m5 | assert | variable | tests/validators/test_model.py | test_model_class_instance_subclass_revalidate | 609 | null | |
pydantic/pydantic-core | import pytest
from pydantic_core import SchemaSerializer, core_schema
def test_nullable():
s = SchemaSerializer(core_schema.nullable_schema(core_schema.int_schema()))
assert s.to_python(None) is None
assert s.to_python(1) == 1
assert s.to_python(None, mode='json') is None
assert s.to_python(1, mod... | b'1' | assert | string_literal | tests/serializers/test_nullable.py | test_nullable | 12 | null | |
pydantic/pydantic-core | import json
from enum import IntEnum
import pytest
from pydantic_core import CoreConfig, SchemaSerializer, core_schema
def test_int_to_float():
"""
See https://github.com/pydantic/pydantic-core/pull/866
"""
s = SchemaSerializer(core_schema.float_schema())
v_plain = s.to_python(1)
assert v_pl... | 1 | assert | numeric_literal | tests/serializers/test_simple.py | test_int_to_float | 72 | null | |
pydantic/pydantic-core | import pickle
import pytest
from pydantic_core import SchemaValidator
from pydantic_core import core_schema as cs
@pytest.mark.parametrize('pickle_protocol', range(1, pickle.HIGHEST_PROTOCOL + 1))
def test_pickle(pickle_protocol: int) -> None:
v1 = SchemaValidator(cs.bool_schema())
assert v1.validate_python(... | repr(v2) | assert | func_call | tests/test_build.py | test_pickle | 21 | null | |
pydantic/pydantic-core | from datetime import date, datetime, time, timedelta, timezone
import pytest
from pydantic_core import SchemaSerializer, core_schema
def tz(**kwargs):
return timezone(timedelta(**kwargs))
@pytest.mark.parametrize(
't,expected_to_python,expected_to_json,expected_to_python_dict,expected_to_json_dict,mode',
... | t | assert | variable | tests/serializers/test_datetime.py | test_config_time | 293 | null | |
pydantic/pydantic-core | from collections.abc import Mapping
import pytest
from dirty_equals import IsStrictDict
from inline_snapshot import snapshot
from pydantic_core import SchemaValidator, ValidationError, core_schema
def test_nullable():
v = SchemaValidator(core_schema.nullable_schema(core_schema.list_schema(core_schema.str_schema(... | ['ab'] | assert | collection | tests/validators/test_allow_partial.py | test_nullable | 301 | null | |
pydantic/pydantic-core | import dataclasses
import ipaddress
import json
import platform
import re
import sys
from collections import namedtuple
from datetime import date, datetime, time, timedelta, timezone
from decimal import Decimal
from enum import Enum
from math import inf, isinf, isnan, nan
from pathlib import Path
from typing import Cla... | f | assert | variable | tests/serializers/test_any.py | test_unknown_type | 317 | null | |
pydantic/pydantic-core | import math
import re
import sys
from collections.abc import Mapping
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Union
import pytest
from dirty_equals import FunctionCheck, HasRepr, IsStr
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, c... | {} | assert | collection | tests/validators/test_model_fields.py | test_extra_behavior_allow_keys_validation | 1,821 | null | |
pydantic/pydantic-core | import json
import platform
import re
import pytest
from dirty_equals import IsFloatNan, IsList
import pydantic_core
from pydantic_core import (
CoreConfig,
PydanticSerializationError,
SchemaSerializer,
SchemaValidator,
ValidationError,
core_schema,
from_json,
to_json,
to_jsonable_... | {1: 2} | assert | collection | tests/test_json.py | test_dict | 173 | null | |
pydantic/pydantic-core | import dataclasses
import ipaddress
import json
import platform
import re
import sys
from collections import namedtuple
from datetime import date, datetime, time, timedelta, timezone
from decimal import Decimal
from enum import Enum
from math import inf, isinf, isnan, nan
from pathlib import Path
from typing import Cla... | 1 | assert | numeric_literal | tests/serializers/test_any.py | test_enum | 402 | null | |
pydantic/pydantic-core | from dataclasses import dataclass
from enum import Enum
from typing import Literal, Union
import pytest
from pydantic_core import SchemaError, SchemaSerializer, core_schema
from ..conftest import plain_repr
def test_bool_literal():
s = SchemaSerializer(core_schema.literal_schema([False]))
assert 'expected_... | plain_repr(s) | assert | func_call | tests/serializers/test_literal.py | test_bool_literal | 72 | null | |
pydantic/pydantic-core | import copy
import json
import platform
import re
import zoneinfo
from datetime import date, datetime, time, timedelta, timezone, tzinfo
from decimal import Decimal
import pytest
from pydantic_core import SchemaError, SchemaValidator, ValidationError, core_schema
from pydantic_core import core_schema as cs
from ..co... | dt | assert | variable | tests/validators/test_datetime.py | test_keep_tz | 119 | null | |
pydantic/pydantic-core | import platform
import re
import sys
from decimal import Decimal
from numbers import Number
from typing import Any, Union
import pytest
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, core_schema
from ..conftest import Err, PyAndJson, plain_repr
def fruit_enum_fixture():
fro... | 'r""' | assert | string_literal | tests/validators/test_string.py | test_backtracking_regex_python | 387 | null | |
pydantic/pydantic-core | import json
from dataclasses import dataclass
from datetime import date, datetime
from uuid import UUID
import pytest
from pydantic_core import SchemaSerializer, SchemaValidator, core_schema, to_json
class TestBenchmarkSimpleModel:
def core_schema(self):
class CoreModel:
__slots__ = '__dict_... | self.data | assert | complex_expr | tests/benchmarks/test_serialization_micro.py | test_core_dict | TestBenchmarkSimpleModel | 47 | null |
pydantic/pydantic-core | import math
import re
import sys
from collections.abc import Mapping
from dataclasses import dataclass
from datetime import datetime
from typing import Any, Union
import pytest
from dirty_equals import FunctionCheck, HasRepr, IsStr
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, c... | 'y' | assert | string_literal | tests/validators/test_model_fields.py | test_extra_behavior_forbid | 1,743 | null | |
pydantic/pydantic-core | import re
import sys
from collections import defaultdict
from copy import deepcopy
from decimal import Decimal
from typing import Any, Callable, Union
import pytest
from dirty_equals import HasRepr, IsInstance
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, core_schema
from pydant... | m3 | assert | variable | tests/validators/test_model.py | test_model_class_instance_direct | 513 | null | |
pydantic/pydantic-core | import re
import sys
from decimal import Decimal
from enum import Enum, IntEnum, IntFlag
import pytest
from pydantic_core import SchemaError, SchemaValidator, ValidationError, core_schema
def test_float_enum():
class MyEnum(float, Enum):
a = 1.5
b = 2.5
c = 3.0
v = SchemaValidator(co... | MyEnum.c | assert | complex_expr | tests/validators/test_enums.py | test_float_enum | 135 | null | |
pydantic/pydantic-core | import decimal
import json
import platform
import sys
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal
from enum import Enum
from typing import Any
from uuid import UUID
import pytest
from dirty_equals import IsStr
import pydantic_core
from pydantic_core import (
ArgsKwargs,
... | 'x' | assert | string_literal | tests/benchmarks/test_micro_benchmarks.py | f | 1,344 | null | |
pydantic/pydantic-core | import json
import re
from datetime import date
from uuid import UUID
import pytest
from pydantic_core import PydanticSerializationError, SchemaSerializer, core_schema
def test_to_string_when_used_always():
s = SchemaSerializer(core_schema.any_schema(serialization=core_schema.format_ser_schema('', when_used='alw... | '123' | assert | string_literal | tests/serializers/test_format.py | test_to_string_when_used_always | 59 | null | |
pydantic/pydantic-core | from pydantic_core import SchemaSerializer, core_schema
def test_json_int():
s = SchemaSerializer(core_schema.json_schema(core_schema.int_schema()))
assert s.to_python(1) == 1
assert s.to_python(1, round_trip=True) == '1'
assert s.to_python(1, mode='json') == 1
assert s.to_python(1, mode='json', r... | b'1' | assert | string_literal | tests/serializers/test_json.py | test_json_int | 11 | null | |
pydantic/pydantic-core | import datetime
import platform
import re
from copy import deepcopy
from dataclasses import dataclass
from typing import Any
import pytest
from dirty_equals import HasRepr
from pydantic_core import CoreConfig, SchemaValidator, ValidationError, core_schema
from pydantic_core import core_schema as cs
from ..conftest i... | m2 | assert | variable | tests/validators/test_function.py | test_validate_assignment | 450 | null | |
pydantic/pydantic-core | import re
from copy import deepcopy
from typing import Optional, Union
import pytest
from dirty_equals import HasRepr, IsInstance
from pydantic_core import CoreConfig, MultiHostUrl, SchemaError, SchemaValidator, Url, ValidationError, core_schema
from ..conftest import Err, PyAndJson
def url_validator_fixture():
... | 'p' | assert | string_literal | tests/validators/test_url.py | test_url_build_not_encode_credentials | 1,360 | null | |
pydantic/pydantic-core | import pytest
from pydantic_core import SchemaValidator, ValidationError, core_schema
from .conftest import PyAndJson
def test_validate_assignment_with_context():
def f1(input_value, info):
info.context['f1'] = input_value
return input_value + f'| context: {info.context}'
def f2(input_value,... | {'f1'} | assert | collection | tests/test_validation_context.py | test_validate_assignment_with_context | 118 | null | |
pydantic/pydantic-core | import json
from functools import partial
import pytest
from pydantic_core import (
PydanticSerializationError,
SchemaSerializer,
core_schema,
)
def as_list(*items):
return list(items)
def as_tuple(*items):
return tuple(items)
def test_filter_runtime():
v = SchemaSerializer(
core_sc... | [2, 3] | assert | collection | tests/serializers/test_list_tuple.py | test_filter_runtime | 176 | null | |
pydantic/pydantic-core | import re
from collections import deque
from typing import Any
import pytest
from dirty_equals import IsNonNegative, IsTuple
from pydantic_core import SchemaValidator, ValidationError, core_schema
from ..conftest import Err, PyAndJson, infinite_generator
def test_tuple_fix_extra_any():
v = SchemaValidator(
... | ('1',) | assert | collection | tests/validators/test_tuple.py | test_tuple_fix_extra_any | 435 | null | |
pydantic/pydantic-core | import re
import sys
from decimal import Decimal
from enum import Enum, IntEnum, IntFlag
import pytest
from pydantic_core import SchemaError, SchemaValidator, ValidationError, core_schema
def test_plain_enum():
class MyEnum(Enum):
a = 1
b = 2
v = SchemaValidator(core_schema.enum_schema(MyEnu... | MyEnum.b | assert | complex_expr | tests/validators/test_enums.py | test_plain_enum | 20 | null | |
pydantic/pydantic-core | import pytest
from dirty_equals import IsStr
from pydantic_core import SchemaSerializer, core_schema
def gen_ok(*things):
yield from things
def gen_error(*things):
yield from things
raise ValueError('oops')
def test_any_iter():
s = SchemaSerializer(core_schema.any_schema())
gen = s.to_python(gen... | b'b' | assert | string_literal | tests/serializers/test_generator.py | test_any_iter | 41 | null | |
pydantic/pydantic-core | import dataclasses
import ipaddress
import json
import platform
import re
import sys
from collections import namedtuple
from datetime import date, datetime, time, timedelta, timezone
from decimal import Decimal
from enum import Enum
from math import inf, isinf, isnan, nan
from pathlib import Path
from typing import Cla... | h2 | assert | variable | tests/serializers/test_any.py | test_any_config_timedelta_float | 191 | null | |
pydantic/pydantic-core | from __future__ import annotations as _annotations
from datetime import date, datetime, time
from typing import Any, Callable
from pydantic_core import (
CoreSchema,
ErrorDetails,
PydanticKnownError,
SchemaError,
SchemaSerializer,
SchemaValidator,
ValidationError,
core_schema,
)
def f... | str(exc) | assert | func_call | tests/test_typing.py | test_wrong_function_signature | 206 | null | |
pydantic/pydantic-core | import platform
import sys
import weakref
from collections import deque
from dataclasses import dataclass
from typing import Any, Callable, Union, cast
import pytest
from pydantic_core import (
ArgsKwargs,
PydanticUndefined,
PydanticUseDefault,
SchemaError,
SchemaValidator,
Some,
Validatio... | {} | assert | collection | tests/validators/test_with_default.py | test_deepcopy_mutable_defaults | 476 | null | |
pydantic/pydantic-core | import math
import platform
import re
import weakref
from collections.abc import Mapping
from typing import Any, Union
import pytest
from dirty_equals import FunctionCheck
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, core_schema
from pydantic_core.core_schema import ExtraBehavi... | 'foo' | assert | string_literal | tests/validators/test_typed_dict.py | __getitem__ | GetItemThing | 595 | null |
pydantic/pydantic-core | import json
from enum import IntEnum
import pytest
from pydantic_core import CoreConfig, SchemaSerializer, core_schema
def test_int_to_float():
"""
See https://github.com/pydantic/pydantic-core/pull/866
"""
s = SchemaSerializer(core_schema.float_schema())
v_plain = s.to_python(1)
assert v_pla... | int | assert | variable | tests/serializers/test_simple.py | test_int_to_float | 73 | null | |
pydantic/pydantic-core | import dataclasses
import re
from datetime import date, datetime
import pytest
from pydantic_core import SchemaValidator, ValidationError, core_schema
from .conftest import Err
def test_bool():
v = SchemaValidator(core_schema.bool_schema())
assert v.validate_strings('true') is | True | assert | bool_literal | tests/test_validate_strings.py | test_bool | 15 | null | |
pydantic/pydantic-core | import dataclasses
import ipaddress
import json
import platform
import re
import sys
from collections import namedtuple
from datetime import date, datetime, time, timedelta, timezone
from decimal import Decimal
from enum import Enum
from math import inf, isinf, isnan, nan
from pathlib import Path
from typing import Cla... | v | assert | variable | tests/serializers/test_any.py | test_recursion | 215 | null | |
pydantic/pydantic-core | import enum
import os
import pickle
import re
import subprocess
import sys
from decimal import Decimal
from typing import Any, Optional
from unittest.mock import patch
import pytest
from dirty_equals import HasRepr, IsInstance, IsJson, IsStr
from pydantic_core import (
CoreConfig,
PydanticCustomError,
Pyd... | 1 | assert | numeric_literal | tests/test_errors.py | test_validation_error_cause_contents | 562 | null | |
pydantic/pydantic-core | import pytest
from dirty_equals import IsStr
from pydantic_core import SchemaSerializer, core_schema
def gen_ok(*things):
yield from things
def gen_error(*things):
yield from things
raise ValueError('oops')
def test_generator_any_iter():
s = SchemaSerializer(core_schema.generator_schema(core_schema.... | 0 | assert | numeric_literal | tests/serializers/test_generator.py | test_generator_any_iter | 21 | null | |
pydantic/pydantic-core | import dataclasses
import ipaddress
import json
import platform
import re
import sys
from collections import namedtuple
from datetime import date, datetime, time, timedelta, timezone
from decimal import Decimal
from enum import Enum
from math import inf, isinf, isnan, nan
from pathlib import Path
from typing import Cla... | Foo | assert | variable | tests/serializers/test_any.py | test_any_model | 518 | null | |
pydantic/pydantic-core | from __future__ import annotations
import dataclasses
import json
import uuid
import warnings
from decimal import Decimal
from typing import Any, ClassVar, Literal, Union
import pytest
from pydantic_core import PydanticSerializationUnexpectedValue, SchemaSerializer, core_schema
def model_serializer() -> SchemaSeria... | 1 | assert | numeric_literal | tests/serializers/test_union.py | test_union_float_int | 675 | null | |
pydantic/pydantic-core | import pytest
from dirty_equals import IsStr
from pydantic_core import SchemaSerializer, core_schema
def gen_ok(*things):
yield from things
def gen_error(*things):
yield from things
raise ValueError('oops')
def test_any_iter():
s = SchemaSerializer(core_schema.any_schema())
gen = s.to_python(gen... | 'a' | assert | string_literal | tests/serializers/test_generator.py | test_any_iter | 39 | null | |
pydantic/pydantic-core | import pytest
from pydantic_core import SchemaError, SchemaValidator, core_schema
from ..conftest import plain_repr
def test_use_after():
v = SchemaValidator(
core_schema.tuple_positional_schema(
[
core_schema.definitions_schema(
core_schema.definition_refe... | (1, 2) | assert | collection | tests/validators/test_definitions.py | test_use_after | 128 | null | |
pydantic/pydantic-core | from dataclasses import dataclass
from typing import Callable, Optional
import pytest
from typing_extensions import TypedDict
from pydantic_core import SchemaSerializer, SchemaValidator, core_schema
def test_serialize_as_any_with_unrelated_models() -> None:
class Parent:
x: int
class Other:
... | {} | assert | collection | tests/serializers/test_serialize_as_any.py | test_serialize_as_any_with_unrelated_models | 158 | null | |
pydantic/pydantic-core | import pytest
from pydantic_core import SchemaValidator, ValidationError, core_schema
def test_lax_or_strict():
v = SchemaValidator(core_schema.lax_or_strict_schema(core_schema.str_schema(), core_schema.int_schema()))
# validator is default - lax so with no runtime arg, we're in lax mode, and we use the strin... | 'aaa' | assert | string_literal | tests/validators/test_lax_or_strict.py | test_lax_or_strict | 9 | null | |
pydantic/pydantic-core | import platform
import re
import sys
from decimal import Decimal
from numbers import Number
from typing import Any, Union
import pytest
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, core_schema
from ..conftest import Err, PyAndJson, plain_repr
def fruit_enum_fixture():
fro... | 'abc' | assert | string_literal | tests/validators/test_string.py | test_compiled_regex | 428 | null | |
pydantic/pydantic-core | import pickle
import pytest
from pydantic_core import MultiHostUrl, SchemaSerializer, SchemaValidator, Url, core_schema
def test_any():
url = Url('https://ex.com')
multi_host_url = MultiHostUrl('https://ex.com,ex.org/path')
s = SchemaSerializer(core_schema.any_schema())
assert s.to_python(url) == ur... | Url | assert | variable | tests/serializers/test_url.py | test_any | 74 | null | |
pydantic/pydantic-core | import math
import pytest
from pydantic_core import SchemaSerializer, core_schema
@pytest.mark.parametrize(
'value,expected',
[
(complex(-1.23e-4, 567.89), '-0.000123+567.89j'),
(complex(0, -1.23), '-1.23j'),
(complex(1.5, 0), '1.5+0j'),
(complex(1, 2), '1+2j'),
(compl... | value.imag | assert | complex_expr | tests/serializers/test_complex.py | test_complex_json | 34 | null | |
pydantic/pydantic-core | import re
import pytest
from dirty_equals import HasRepr, IsStr
from pydantic_core import CoreConfig, SchemaValidator, ValidationError
from pydantic_core import core_schema as cs
from ..conftest import Err, PyAndJson
def test_too_long(py_and_json: PyAndJson):
v = py_and_json({'type': 'generator', 'items_schema'... | [1, 2] | assert | collection | tests/validators/test_generator.py | test_too_long | 114 | null | |
pydantic/pydantic-core | from enum import Enum
from pydantic_core import SchemaSerializer, core_schema
def test_json_or_python():
def s1(v: int) -> int:
return v + 1
def s2(v: int) -> int:
return v + 2
s = SchemaSerializer(
core_schema.json_or_python_schema(
core_schema.int_schema(serializati... | 2 | assert | numeric_literal | tests/serializers/test_json_or_python.py | test_json_or_python | 21 | null | |
pydantic/pydantic-core | from datetime import timedelta
import pytest
from pydantic_core import SchemaSerializer, core_schema
@pytest.mark.parametrize(
'td,expected_to_python,expected_to_json,expected_to_python_dict,expected_to_json_dict,mode',
[
(timedelta(hours=2), 7200000.0, b'7200000.0', {'7200000': 'foo'}, b'{"7200000":... | td | assert | variable | tests/serializers/test_timedelta.py | test_config_timedelta | 183 | null | |
pydantic/pydantic-core | import pytest
from pydantic_core import PydanticUndefined, SchemaValidator, ValidationError, core_schema
def test_revalidate_with_default():
class RootModel:
__slots__ = '__dict__', '__pydantic_fields_set__', '__pydantic_extra__', '__pydantic_private__'
root: int = 42
v = SchemaValidator(
... | set() | assert | func_call | tests/validators/test_model_root.py | test_revalidate_with_default | 74 | null | |
pydantic/pydantic-core | import re
from enum import Enum
from typing import Any, Callable
import pytest
from pydantic_core import SchemaError, SchemaValidator, ValidationError, core_schema
from pydantic_core import core_schema as cs
from ..conftest import Err, PyAndJson, plain_repr
def test_str_enum_values():
class Foo(str, Enum):
... | Foo.foo | assert | complex_expr | tests/validators/test_literal.py | test_str_enum_values | 251 | null | |
pydantic/pydantic-core | import decimal
import json
import platform
import sys
from datetime import date, datetime, timedelta, timezone
from decimal import Decimal
from enum import Enum
from typing import Any
from uuid import UUID
import pytest
from dirty_equals import IsStr
import pydantic_core
from pydantic_core import (
ArgsKwargs,
... | 1 | assert | numeric_literal | tests/benchmarks/test_micro_benchmarks.py | test_model_instance | 1,143 | null | |
pydantic/pydantic-core | import typing
import pytest
from pydantic_core import SchemaError, SchemaValidator, ValidationError, core_schema
from pydantic_core import core_schema as cs
def test_is_instance():
v = SchemaValidator(cs.is_instance_schema(cls=Foo))
foo = Foo()
assert v.validate_python(foo) == | foo | assert | variable | tests/validators/test_is_instance.py | test_is_instance | 31 | null | |
pydantic/pydantic-core | import re
from enum import Enum
import pytest
from pydantic_core import SchemaValidator, ValidationError, core_schema
from ..conftest import Err, PyAndJson, plain_repr
def test_enum() -> None:
class MyEnum(Enum):
a = 'a'
b = 'b'
enum_schema = core_schema.lax_or_strict_schema(
core_s... | MyEnum.a | assert | complex_expr | tests/validators/test_json.py | test_enum | 166 | null | |
pydantic/pydantic-core | import enum
import os
import pickle
import re
import subprocess
import sys
from decimal import Decimal
from typing import Any, Optional
from unittest.mock import patch
import pytest
from dirty_equals import HasRepr, IsInstance, IsJson, IsStr
from pydantic_core import (
CoreConfig,
PydanticCustomError,
Pyd... | ctx | assert | variable | tests/test_errors.py | test_pydantic_value_error_nested_ctx | 51 | null | |
pydantic/pydantic-core | import math
import platform
import re
import weakref
from collections.abc import Mapping
from typing import Any, Union
import pytest
from dirty_equals import FunctionCheck
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, core_schema
from pydantic_core.core_schema import ExtraBehavi... | {} | assert | collection | tests/validators/test_typed_dict.py | test_empty_model | 742 | null | |
pydantic/pydantic-core | from enum import Enum
import pytest
from pydantic_core import SchemaSerializer, core_schema
def test_str_enum():
class MyEnum(str, Enum):
a = 'a'
b = 'b'
v = SchemaSerializer(core_schema.enum_schema(MyEnum, list(MyEnum.__members__.values()), sub_type='str'))
# debug(v)
assert v.to_p... | 'a' | assert | string_literal | tests/serializers/test_enum.py | test_str_enum | 65 | null | |
pydantic/pydantic-core | import dataclasses
import re
from collections import namedtuple
from functools import partial
import pytest
from pydantic_core import ArgsKwargs, SchemaValidator, ValidationError
from pydantic_core import core_schema as cs
from ..conftest import Err, PyAndJson, plain_repr
def test_in_union():
def my_function(a)... | 1 | assert | numeric_literal | tests/validators/test_call.py | test_in_union | 109 | null | |
pydantic/pydantic-core | import pickle
import pytest
from pydantic_core import MultiHostUrl, SchemaSerializer, SchemaValidator, Url, core_schema
def test_url():
v = SchemaValidator(core_schema.url_schema())
s = SchemaSerializer(core_schema.url_schema())
url = v.validate_python('https://example.com')
assert isinstance(url, U... | url | assert | variable | tests/serializers/test_url.py | test_url | 17 | null | |
pydantic/pydantic-core | import datetime
import platform
import sys
from dataclasses import dataclass
from typing import Optional
import pytest
from dirty_equals import AnyThing, HasAttributes, IsList, IsPartialDict, IsStr, IsTuple
import pydantic_core
from pydantic_core import CoreConfig, SchemaError, SchemaValidator, ValidationError, core_... | [[]] | assert | collection | tests/validators/test_definitions_recursive.py | test_definition_list | 391 | null | |
pydantic/pydantic-core | import platform
import sys
import weakref
from collections import deque
from dataclasses import dataclass
from typing import Any, Callable, Union, cast
import pytest
from pydantic_core import (
ArgsKwargs,
PydanticUndefined,
PydanticUseDefault,
SchemaError,
SchemaValidator,
Some,
Validatio... | [] | assert | collection | tests/validators/test_with_default.py | test_deepcopy_mutable_defaults | 475 | null | |
pydantic/pydantic-core | import pytest
from pydantic_core import SchemaSerializer, core_schema
def test_nullable():
s = SchemaSerializer(core_schema.nullable_schema(core_schema.int_schema()))
assert s.to_python(None) is None
assert s.to_python(1) == | 1 | assert | numeric_literal | tests/serializers/test_nullable.py | test_nullable | 9 | null | |
pydantic/pydantic-core | import pickle
import re
from datetime import datetime, timedelta, timezone
import pytest
from pydantic_core import core_schema
from pydantic_core._pydantic_core import SchemaValidator, ValidationError
def test_basic_schema_validator():
v = SchemaValidator(
{'type': 'dict', 'strict': True, 'keys_schema': ... | {} | assert | collection | tests/validators/test_pickling.py | test_basic_schema_validator | 17 | null | |
pydantic/pydantic-core | import pytest
from dirty_equals import IsStr
from pydantic_core import SchemaSerializer, core_schema
def gen_ok(*things):
yield from things
def gen_error(*things):
yield from things
raise ValueError('oops')
def test_generator_any():
s = SchemaSerializer(core_schema.generator_schema(core_schema.any_s... | 4 | assert | numeric_literal | tests/serializers/test_generator.py | test_generator_any | 61 | null | |
pydantic/pydantic-core | import re
from collections import deque
from typing import Any
import pytest
from dirty_equals import IsNonNegative, IsTuple
from pydantic_core import SchemaValidator, ValidationError, core_schema
from ..conftest import Err, PyAndJson, infinite_generator
def test_extra_arguments(py_and_json: PyAndJson):
v = py_... | (1, 2) | assert | collection | tests/validators/test_tuple.py | test_extra_arguments | 247 | null | |
pydantic/pydantic-core | import pytest
from pydantic_core import SchemaValidator, ValidationError, core_schema
from .conftest import PyAndJson
def test_isinstance(py_and_json: PyAndJson):
def f(input_value, validator, info):
if 'error' in info.context:
raise ValueError('wrong')
return validator(input_value)
... | True | assert | bool_literal | tests/test_validation_context.py | test_isinstance | 84 | null | |
pydantic/pydantic-core | import json
import platform
import re
import sys
from collections import deque
from operator import attrgetter
from pathlib import Path
import pytest
from pydantic_core import (
PydanticOmit,
PydanticSerializationError,
PydanticSerializationUnexpectedValue,
SchemaSerializer,
core_schema,
)
def re... | 0 | assert | numeric_literal | tests/serializers/test_functions.py | test_function_wrap_model | 537 | null | |
pydantic/pydantic-core | import re
from enum import Enum
from typing import Any, Callable
import pytest
from pydantic_core import SchemaError, SchemaValidator, ValidationError, core_schema
from pydantic_core import core_schema as cs
from ..conftest import Err, PyAndJson, plain_repr
def test_enum_value():
class FooEnum(Enum):
fo... | FooEnum.foo | assert | complex_expr | tests/validators/test_literal.py | test_enum_value | 205 | null | |
pydantic/pydantic-core | import copy
import json
import platform
import re
import zoneinfo
from datetime import date, datetime, time, timedelta, timezone, tzinfo
from decimal import Decimal
import pytest
from pydantic_core import SchemaError, SchemaValidator, ValidationError, core_schema
from pydantic_core import core_schema as cs
from ..co... | 'UTC' | assert | string_literal | tests/validators/test_datetime.py | test_custom_timezone_utc_repr | 213 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.