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
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_to_jsonable_python
240
null
pydantic/pydantic-core
import copy import pickle import pytest from typing_extensions import ( # noqa: UP035 (https://github.com/astral-sh/ruff/pull/18476) get_args, get_origin, get_type_hints, ) from typing_inspection import typing_objects from typing_inspection.introspection import UNKNOWN, AnnotationSource, inspect_annotatio...
'test'
assert
string_literal
tests/test_misc.py
test_schema_error
45
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_custom_serializer(): s = SchemaSerializer(core_schema.any_schema(serialization=core_...
[1, 2]
assert
collection
tests/serializers/test_generator.py
test_custom_serializer
148
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
390
null
pydantic/pydantic-core
from pydantic_core import SchemaSerializer, core_schema def test_custom_serializer(): s = SchemaSerializer(core_schema.any_schema(serialization=core_schema.simple_ser_schema('json'))) assert s.to_python({1: 2}) ==
{1: 2}
assert
collection
tests/serializers/test_json.py
test_custom_serializer
43
null
pydantic/pydantic-core
import platform import re import sys from functools import wraps from inspect import Parameter, signature from typing import Any, Union, get_type_hints import pytest from pydantic_core import ArgsKwargs, SchemaError, SchemaValidator, ValidationError, core_schema from pydantic_core import core_schema as cs from ..con...
(1, 2)
assert
collection
tests/validators/test_arguments.py
test_function_positional_only_default
1,093
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....
2
assert
numeric_literal
tests/serializers/test_generator.py
test_generator_any_iter
26
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, ...
m2
assert
variable
tests/benchmarks/test_micro_benchmarks.py
test_model_instance
1,142
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 v.isinstance...
bar
assert
variable
tests/validators/test_is_instance.py
test_is_instance
34
null
pydantic/pydantic-core
import copy import pickle import pytest from typing_extensions import ( # noqa: UP035 (https://github.com/astral-sh/ruff/pull/18476) get_args, get_origin, get_type_hints, ) from typing_inspection import typing_objects from typing_inspection.introspection import UNKNOWN, AnnotationSource, inspect_annotatio...
'int'
assert
string_literal
tests/test_misc.py
test_validation_error
54
null
pydantic/pydantic-core
import base64 import json from enum import Enum import pytest from pydantic_core import PydanticSerializationError, SchemaSerializer, core_schema, to_json def test_bytes_fallback(): s = SchemaSerializer(core_schema.bytes_schema()) with pytest.warns( UserWarning, match=r'Expected `bytes` - ser...
b'123'
assert
string_literal
tests/serializers/test_bytes.py
test_bytes_fallback
63
null
pydantic/pydantic-core
import math import re import pytest from dirty_equals import FunctionCheck, HasAttributes, IsInstance from pydantic_core import CoreConfig, SchemaValidator, ValidationError from pydantic_core import core_schema as cs from .conftest import Err, plain_repr def test_on_field(): v = SchemaValidator(cs.str_schema(mi...
r
assert
variable
tests/test_config.py
test_on_field
16
null
pydantic/pydantic-core
import json import re import sys from datetime import datetime, timezone from typing import Optional import pytest from dirty_equals import AnyThing, IsBytes, IsStr, IsTuple from hypothesis import given, strategies from typing_extensions import TypedDict from pydantic_core import SchemaSerializer, SchemaValidator, Va...
1
assert
numeric_literal
tests/test_hypothesis.py
test_urls_text
161
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 @pytest.mark.parametrize('fail_fast', [True, False]) def test...
()
assert
collection
tests/validators/test_tuple.py
test_empty_positional_tuple
64
null
pydantic/pydantic-core
import pytest from pydantic_core import PydanticUndefined, SchemaValidator, ValidationError, core_schema def test_revalidate(): class RootModel: __slots__ = '__dict__', '__pydantic_fields_set__', '__pydantic_extra__', '__pydantic_private__' root: list[int] v = SchemaValidator( core_sc...
[1, 2]
assert
collection
tests/validators/test_model_root.py
test_revalidate
47
null
pydantic/pydantic-core
import dataclasses import platform import re import sys import weakref from typing import Any, ClassVar, Optional, Union import pytest from dirty_equals import IsListOrTuple, IsStr from pydantic_core import ArgsKwargs, SchemaValidator, ValidationError, core_schema from pydantic_core.core_schema import ExtraBehavior ...
foo
assert
variable
tests/validators/test_dataclasses.py
test_dataclass_subclass_strict_never_revalidate
326
null
pydantic/pydantic-core
import pytest from pydantic_core import PydanticOmit, SchemaError, SchemaValidator, ValidationError, core_schema from pydantic_core import core_schema as cs from .conftest import PyAndJson def test_omit(py_and_json: PyAndJson): def omit(v, info): if v == 'omit': raise PydanticOmit eli...
'foo'
assert
string_literal
tests/test_isinstance.py
test_omit
66
null
pydantic/pydantic-core
import pytest from pydantic_core import PydanticUndefined, SchemaValidator, ValidationError, core_schema def test_revalidate(): class RootModel: __slots__ = '__dict__', '__pydantic_fields_set__', '__pydantic_extra__', '__pydantic_private__' root: list[int] v = SchemaValidator( core_sc...
m
assert
variable
tests/validators/test_model_root.py
test_revalidate
51
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( 'dt,expected_to_python,expected_to_json,expected_to_python_dict,expected_to_json_dict,mode', ...
dt
assert
variable
tests/serializers/test_datetime.py
test_config_datetime
167
null
pydantic/pydantic-core
import pytest from pydantic_core import SchemaValidator, ValidationError from pydantic_core import core_schema as cs def test_json_or_python(): class Foo(str): def __eq__(self, o: object) -> bool: if isinstance(o, Foo) and super().__eq__(o): return True return False...
Foo('abc')
assert
func_call
tests/validators/test_json_or_python.py
test_json_or_python
19
null
pydantic/pydantic-core
import pytest from pydantic_core import SchemaError, SchemaValidator, ValidationError, core_schema def test_is_subclass_basic(): v = SchemaValidator(core_schema.is_subclass_schema(Foo)) assert v.validate_python(Foo) ==
Foo
assert
variable
tests/validators/test_is_subclass.py
test_is_subclass_basic
20
null
pydantic/pydantic-core
import dataclasses import json import platform import warnings from functools import cached_property from random import randint from typing import Any, ClassVar import pytest from dirty_equals import IsJson from pydantic_core import ( PydanticSerializationError, SchemaSerializer, SchemaValidator, core...
b'{}'
assert
string_literal
tests/serializers/test_model.py
test_exclude_if
229
null
pydantic/pydantic-core
import copy import pickle import pytest from typing_extensions import ( # noqa: UP035 (https://github.com/astral-sh/ruff/pull/18476) get_args, get_origin, get_type_hints, ) from typing_inspection import typing_objects from typing_inspection.introspection import UNKNOWN, AnnotationSource, inspect_annotatio...
1
assert
numeric_literal
tests/test_misc.py
test_validation_error
55
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...
1
assert
numeric_literal
tests/serializers/test_functions.py
test_function_wrap_model
539
null
pydantic/pydantic-core
import pickle import pytest from pydantic_core import SchemaValidator from pydantic_core import core_schema as cs def test_try_self_schema_discriminator(): """Trying to use self-schema when it shouldn't be used""" v = SchemaValidator(cs.tagged_union_schema(choices={'int': cs.int_schema()}, discriminator='sel...
repr(v)
assert
func_call
tests/test_build.py
test_try_self_schema_discriminator
39
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...
TzInfo(HOUR))
self.assertNotEqual
func_call
tests/test_tzinfo.py
test_comparison
TestTzInfo
150
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, 2]
assert
collection
tests/serializers/test_union.py
test_custom_serializer
704
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...
None
assert
none_literal
tests/serializers/test_any.py
test_ser_json_inf_nan_with_any
628
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
429
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_int_literal(): s = SchemaSerializer(core_schema.literal_schema([1, 2, 3])) r = plain_repr(s)...
r
assert
variable
tests/serializers/test_literal.py
test_int_literal
15
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_include(): v = SchemaSerializer( core_schema.generator_schema( c...
[1, 3]
assert
collection
tests/serializers/test_generator.py
test_include
125
null
pydantic/pydantic-core
import platform import weakref import pytest from dirty_equals import IsInstance from pydantic_core import CoreConfig, SchemaValidator, core_schema from ..conftest import assert_gc def test_model_custom_init_revalidate(): calls = [] class Model: __slots__ = '__dict__', '__pydantic_fields_set__', '_...
m
assert
variable
tests/validators/test_model_init.py
test_model_custom_init_revalidate
406
null
pydantic/pydantic-core
import platform import sys from dataclasses import dataclass from datetime import date, time from enum import Enum, IntEnum from itertools import permutations from typing import Any, Optional, Union from uuid import UUID import pytest from dirty_equals import IsFloat, IsInt from pydantic_core import CoreConfig, Schem...
b
assert
variable
tests/validators/test_union.py
test_smart_union_default_fallback
636
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...
b'1'
assert
string_literal
tests/serializers/test_any.py
test_enum
407
null
pydantic/pydantic-core
import json import re from decimal import Decimal from fractions import Fraction from typing import Any import pytest from dirty_equals import IsStr from pydantic_core import SchemaError, SchemaValidator, ValidationError from pydantic_core import core_schema as cs from ..conftest import Err, PyAndJson, plain_repr i...
int
assert
variable
tests/validators/test_int.py
test_int_subclass
511
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...
None
assert
none_literal
tests/test_errors.py
test_pydantic_value_error_none
61
null
pydantic/pydantic-core
import pytest from pydantic_core import ArgsKwargs, ValidationError from pydantic_core import core_schema as cs from ...conftest import PyAndJson def test_positional_only_validation_error(py_and_json: PyAndJson) -> None: """Test invalid inputs against positional-only parameters: ```python def func(a: in...
(0,)
assert
collection
tests/validators/arguments_v3/test_positional_only.py
test_positional_only_validation_error
64
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.b
assert
complex_expr
tests/validators/test_json.py
test_enum
167
null
pydantic/pydantic-core
from typing import Union from pydantic_core import SchemaSerializer, SchemaValidator, core_schema def test_prebuilt_val_and_ser_used() -> None: class InnerModel: x: int inner_schema = core_schema.model_schema( InnerModel, schema=core_schema.model_fields_schema( {'x': core_...
1
assert
numeric_literal
tests/test_prebuilt.py
test_prebuilt_val_and_ser_used
49
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_unless_none(): s = SchemaSerializer( core_schema.any_schema(serialization=core_schema.format_ser_schema('', ...
'42'
assert
string_literal
tests/serializers/test_format.py
test_to_string_when_used_unless_none
73
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 > LARGEST)
self.assertFalse
complex_expr
tests/test_tzinfo.py
test_comparison
TestTzInfo
161
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 < LARGEST)
self.assertTrue
complex_expr
tests/test_tzinfo.py
test_comparison
TestTzInfo
160
null
pydantic/pydantic-core
import math import re import pytest from dirty_equals import FunctionCheck, HasAttributes, IsInstance from pydantic_core import CoreConfig, SchemaValidator, ValidationError from pydantic_core import core_schema as cs from .conftest import Err, plain_repr def test_on_config(): v = SchemaValidator(cs.str_schema()...
plain_repr(v)
assert
func_call
tests/test_config.py
test_on_config
24
null
pydantic/pydantic-core
import dataclasses import platform import re import sys import weakref from typing import Any, ClassVar, Optional, Union import pytest from dirty_equals import IsListOrTuple, IsStr from pydantic_core import ArgsKwargs, SchemaValidator, ValidationError, core_schema from pydantic_core.core_schema import ExtraBehavior ...
'x'
assert
string_literal
tests/validators/test_dataclasses.py
test_validate_assignment_function
884
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...
b'"a"'
assert
string_literal
tests/serializers/test_enum.py
test_str_enum
66
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...
timedelta(0))
self.assertEqual
func_call
tests/test_tzinfo.py
test_no_args_constructor
TestTzInfo
219
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...
'xx'
assert
string_literal
tests/validators/test_function.py
test_function_plain
408
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]
assert
collection
tests/validators/test_generator.py
test_too_long
113
null
pydantic/pydantic-core
import pytest from pydantic_core import ArgsKwargs, ValidationError from pydantic_core import core_schema as cs from ...conftest import PyAndJson @pytest.mark.parametrize( 'input_value', [ArgsKwargs((), {'a': 'not_an_int'}), {'a': 'not_an_int'}], ) def test_keyword_only_validation_error(py_and_json: PyAndJso...
('a',)
assert
collection
tests/validators/arguments_v3/test_keyword_only.py
test_keyword_only_validation_error
68
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 @pytest.mark.parametrize( 'reverse, err', [ ...
err
assert
variable
tests/validators/test_literal.py
test_mix_int_enum_with_int
335
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...
b'1'
assert
string_literal
tests/serializers/test_json_or_python.py
test_json_or_python
20
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, ...
2
assert
numeric_literal
tests/benchmarks/test_micro_benchmarks.py
test_model_instance
1,144
null
pydantic/pydantic-core
from datetime import date, datetime, time, timedelta, timezone import pytest from pydantic_core import SchemaSerializer, core_schema def test_datetime(): v = SchemaSerializer(core_schema.datetime_schema()) assert v.to_python(datetime(2022, 12, 2, 12, 13, 14)) == datetime(2022, 12, 2, 12, 13, 14) assert ...
b'123'
assert
string_literal
tests/serializers/test_datetime.py
test_datetime
25
null
pydantic/pydantic-core
import math import pytest from pydantic_core import SchemaSerializer, core_schema def test_complex_inference() -> None: s = SchemaSerializer(core_schema.any_schema()) assert s.to_python(1 + 2j) ==
1 + 2j
assert
complex_expr
tests/serializers/test_complex.py
test_complex_inference
44
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_...
None
assert
none_literal
tests/test_json.py
test_null
46
null
pydantic/pydantic-core
import platform import weakref import pytest from dirty_equals import IsInstance from pydantic_core import CoreConfig, SchemaValidator, core_schema from ..conftest import assert_gc def test_model_init(): v = SchemaValidator( core_schema.model_schema( cls=MyModel, schema=core_sche...
m2
assert
variable
tests/validators/test_model_init.py
test_model_init
39
null
pydantic/pydantic-core
import json import os import platform from pathlib import Path from typing import Any, Union import pytest from pydantic_core import SchemaSerializer, core_schema from ..conftest import plain_repr on_pypy = platform.python_implementation() == 'PyPy' def test_model_root(): s = SchemaSerializer(core_schema.model...
b'1'
assert
string_literal
tests/serializers/test_model_root.py
test_model_root
53
null
pydantic/pydantic-core
import collections.abc import re from collections import deque from collections.abc import Iterator from dataclasses import dataclass from typing import Any, Union import pytest from dirty_equals import Contains, HasRepr, IsInstance, IsList, IsStr from pydantic_core import SchemaValidator, ValidationError, core_schem...
[1]
assert
collection
tests/validators/test_list.py
test_bad_iter
351
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(): ...
''
assert
string_literal
tests/validators/test_url.py
test_url_build_not_encode_credentials
1,366
null
pydantic/pydantic-core
import dataclasses import json import platform import sys from typing import ClassVar import pytest from pydantic_core import SchemaSerializer, SchemaValidator, core_schema on_pypy = platform.python_implementation() == 'PyPy' def test_serialization_exclude(): schema = core_schema.dataclass_schema( Foo, ...
b'{}'
assert
string_literal
tests/serializers/test_dataclasses.py
test_serialization_exclude
79
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...
{'f'}
assert
collection
tests/validators/test_model_fields.py
test_extra_behavior_forbid
1,734
null
pydantic/pydantic-core
import platform import re import sys from functools import wraps from inspect import Parameter, signature from typing import Any, Union, get_type_hints import pytest from pydantic_core import ArgsKwargs, SchemaError, SchemaValidator, ValidationError, core_schema from pydantic_core import core_schema as cs from ..con...
ak2
assert
variable
tests/validators/test_arguments.py
test_args_kwargs
29
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_int_literal(): s = SchemaSerializer(core_schema.literal_schema([1, 2, 3])) r = plain_repr(s)...
1
assert
numeric_literal
tests/serializers/test_literal.py
test_int_literal
19
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_positional_empty_extra(py_and_json: PyAndJson): ...
(1,)
assert
collection
tests/validators/test_tuple.py
test_positional_empty_extra
274
null
pydantic/pydantic-core
from decimal import Decimal import pytest from pydantic_core import SchemaSerializer, core_schema def test_decimal(): v = SchemaSerializer(core_schema.decimal_schema()) assert v.to_python(Decimal('123.456')) == Decimal('123.456') assert v.to_python(Decimal('123.456'), mode='json') == '123.456' asser...
b'123'
assert
string_literal
tests/serializers/test_decimal.py
test_decimal
33
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...
'UTC')
self.assertEqual
string_literal
tests/test_tzinfo.py
test_no_args_constructor
TestTzInfo
220
null
pydantic/pydantic-core
import math import re import pytest from dirty_equals import FunctionCheck, HasAttributes, IsInstance from pydantic_core import CoreConfig, SchemaValidator, ValidationError from pydantic_core import core_schema as cs from .conftest import Err, plain_repr def test_on_field(): v = SchemaValidator(cs.str_schema(mi...
True
assert
bool_literal
tests/test_config.py
test_on_field
18
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_dataclass(): @dataclasses.data...
'2'
assert
string_literal
tests/validators/test_call.py
test_dataclass
143
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...
[]
assert
collection
tests/validators/test_model.py
test_model_class_setattr
216
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...
'1'
assert
string_literal
tests/test_typing.py
test_correct_function_signature
193
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_function_positional_tuple(): def f(prefix, value, _info...
['a1']
assert
collection
tests/serializers/test_list_tuple.py
test_function_positional_tuple
380
null
pydantic/pydantic-core
from datetime import timedelta import pytest from pydantic_core import SchemaSerializer, core_schema @pytest.mark.skipif(not pandas, reason='pandas not installed') def test_pandas(): v = SchemaSerializer(core_schema.timedelta_schema()) d = pandas.Timestamp('2023-01-01T02:00:00Z') - pandas.Timestamp('2023-01-...
d
assert
variable
tests/serializers/test_timedelta.py
test_pandas
52
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.a
assert
complex_expr
tests/validators/test_enums.py
test_plain_enum
19
null
pydantic/pydantic-core
import pytest from pydantic_core import SchemaSerializer, SchemaValidator, core_schema from ..conftest import plain_repr def test_chain(): s = SchemaSerializer(core_schema.chain_schema([core_schema.str_schema(), core_schema.int_schema()])) # insert_assert(plain_repr(s)) assert plain_repr(s) == 'SchemaSe...
b'1'
assert
string_literal
tests/serializers/test_other.py
test_chain
15
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...
repr(v)
assert
func_call
tests/validators/test_typed_dict.py
test_aliases_debug
577
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....
3
assert
numeric_literal
tests/serializers/test_generator.py
test_generator_any_iter
27
null
pydantic/pydantic-core
from enum import Enum import pytest from pydantic_core import SchemaSerializer, core_schema def test_plain_enum(): class MyEnum(Enum): a = 1 b = 2 v = SchemaSerializer(core_schema.enum_schema(MyEnum, list(MyEnum.__members__.values()))) # debug(v) assert v.to_python(MyEnum.a) is
MyEnum.a
assert
complex_expr
tests/serializers/test_enum.py
test_plain_enum
16
null
pydantic/pydantic-core
import math import platform import re import sys import pytest from pydantic_core import SchemaValidator, ValidationError from pydantic_core import core_schema as cs from ..conftest import Err EXPECTED_PARSE_ERROR_MESSAGE = 'Input should be a valid complex string following the rules at https://docs.python.org/3/lib...
complex(1, 0)
assert
func_call
tests/validators/test_complex.py
test_json_complex
121
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...
'b'
assert
string_literal
tests/serializers/test_any.py
test_enum
403
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...
m2
assert
variable
tests/validators/test_model.py
test_model_class_strict
638
null
pydantic/pydantic-core
import json import pytest from dirty_equals import IsStrictDict from pydantic_core import SchemaSerializer, core_schema def test_exclude(): s = SchemaSerializer(core_schema.dict_schema(serialization=core_schema.filter_dict_schema(exclude={'a', 'c'}))) assert s.to_python({'a': 1, 'b': 2, 'c': 3, 'd': 4}) == ...
{}
assert
collection
tests/serializers/test_dict.py
test_exclude
51
null
pydantic/pydantic-core
import platform import re import sys from functools import wraps from inspect import Parameter, signature from typing import Any, Union, get_type_hints import pytest from pydantic_core import ArgsKwargs, SchemaError, SchemaValidator, ValidationError, core_schema from pydantic_core import core_schema as cs from ..con...
()
assert
collection
tests/validators/test_arguments.py
test_args_kwargs
24
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...
[1, 2]
assert
collection
tests/serializers/test_list_tuple.py
test_filter_runtime
178
null
pydantic/pydantic-core
import json from enum import Enum import pytest from pydantic_core import PydanticSerializationError, SchemaSerializer, core_schema @pytest.mark.parametrize('schema_type', ['str', 'any']) @pytest.mark.parametrize( 'input_value,expected', [(StrSubclass('foo'), 'foo'), (StrMixin('foo'), 'foo'), (StrEnum.foo, 'foo-...
str
assert
variable
tests/serializers/test_string.py
test_subclass_str
180
null
pydantic/pydantic-core
from enum import Enum import pytest from pydantic_core import SchemaSerializer, core_schema def test_plain_enum(): class MyEnum(Enum): a = 1 b = 2 v = SchemaSerializer(core_schema.enum_schema(MyEnum, list(MyEnum.__members__.values()))) # debug(v) assert v.to_python(MyEnum.a) is MyEn...
1
assert
numeric_literal
tests/serializers/test_enum.py
test_plain_enum
17
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...
'one'
assert
string_literal
tests/validators/test_string.py
test_lax_subclass_plain_enum
269
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_json_type_before_validator(): # See https://github.com/pydantic/pydantic/issues/6573 - when using a # "before" validator to coerce ...
int
assert
variable
tests/validators/test_is_instance.py
test_is_instance_json_type_before_validator
191
null
pydantic/pydantic-core
import pickle import pytest from pydantic_core import SchemaValidator from pydantic_core import core_schema as cs def test_schema_as_string(): v = SchemaValidator(cs.bool_schema()) assert v.validate_python('tRuE') is
True
assert
bool_literal
tests/test_build.py
test_schema_as_string
11
null
django-extensions/django-extensions
from django.core.management import call_command from django.test import TestCase from io import StringIO from unittest.mock import patch class FindTemplateTests(TestCase): @patch("sys.stdout", new_callable=StringIO) def test_finding_template(self, m_stdout): call_command("find_template", "admin/change...
m_stdout.getvalue())
self.assertIn
func_call
tests/test_find_template.py
test_finding_template
FindTemplateTests
13
null
django-extensions/django-extensions
from typing import Optional, Set # noqa from django.conf import settings from django.test.utils import override_settings from tests.management.commands.shell_plus_tests.test_utils import ( AutomaticShellPlusImportsTestCase, ) from tests.test_module_in_project_dir import FourthDerivedClass from tests.testapp.deri...
third or set())
assert_*
func_call
tests/management/commands/shell_plus_tests/test_import_subclasses.py
assert_imports
ImportSubclassesTestCase
153
null
django-extensions/django-extensions
import sys from io import StringIO from django.apps import apps from django.core.management import call_command from django.test import TestCase class ShowPermissionsTests(TestCase): def _run_command(self, *args, **kwargs): """ Utility to run the command and return captured output. """ ...
output.lower())
self.assertIn
func_call
tests/management/commands/test_show_permissions.py
test_should_return_permissions_for_test_model
ShowPermissionsTests
94
null
django-extensions/django-extensions
import unittest from unittest.mock import Mock from django_extensions.management.shells import import_items class TestImportItems(unittest.TestCase): def setUp(self): self.style = Mock() self.style.ERROR = Mock(return_value="ERROR") self.style.SQL_COLTYPE = Mock(return_value="SQL_COLTYPE") ...
callable(result["sin"]))
self.assertTrue
func_call
tests/management/commands/shell_plus_tests/test_shells.py
test_from_import_star
TestImportItems
40
null
django-extensions/django-extensions
import os import shutil from io import StringIO from tempfile import mkdtemp from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from ...testapp.models import Photo from unittest.mock import patch class UnreferencedFilesTests...
m_stdout.getvalue())
self.assertIs
func_call
tests/management/commands/test_unreferenced_files.py
test_should_not_print_any_output
UnreferencedFilesTests
37
null
django-extensions/django-extensions
import json from pathlib import Path from tempfile import TemporaryDirectory import pytest from django.core.management import CommandError, call_command from django.db import connection from django.db.migrations.recorder import MigrationRecorder from django_extensions.management.commands.managestate import ( DEFA...
stdout
assert
variable
tests/management/commands/test_managestate.py
test_dump
TestManageState
67
null
django-extensions/django-extensions
import os import shutil from io import StringIO from tempfile import mkdtemp from django.core.management import CommandError, call_command from django.test import TestCase from django.test.utils import override_settings from ...testapp.models import Photo from unittest.mock import patch class UnreferencedFilesExcep...
CommandError, "MEDIA_ROOT is not set, nothing to do")
self.assertRaisesRegex
complex_expr
tests/management/commands/test_unreferenced_files.py
test_should_raise_ComandError_if_MEDIA_ROOT_is_not_set
UnreferencedFilesExceptionsTests
18
null
django-extensions/django-extensions
from django.test import TestCase from .testapp.models import ( ShortUUIDTestAgregateModel, ShortUUIDTestManyToManyModel, ShortUUIDTestModel_field, ShortUUIDTestModel_pk, ) class ShortUUIDFieldTest(TestCase): def test_UUID_field_pk_agregate_create(self): j = ShortUUIDTestAgregateModel.obje...
len(j.pk) < 23)
self.assertTrue
func_call
tests/test_shortuuid_field.py
test_UUID_field_pk_agregate_create
ShortUUIDFieldTest
27
null
django-extensions/django-extensions
import os import shutil from django.conf import settings from django.core.management import call_command from django.test import TestCase from io import StringIO from unittest.mock import patch TEST_APP = "testapp_with_appconfig" class CreateCommandTests(TestCase): def setUp(self): # noqa self.managem...
m_stdout.getvalue())
self.assertIn
func_call
tests/management/commands/test_create_command.py
test_should_print_management_command_files_only_on_dry_run
CreateCommandTests
61
null
django-extensions/django-extensions
from unittest import mock from django.db import models from django.test import TestCase from tests.testapp.models import ( DummyRelationModel, InheritedFromPostWithUniqFieldCompat, PostWithUniqFieldCompat, ReverseModelCompat, SecondDummyRelationModel, ThirdDummyRelationModel, ) from django_ext...
7)
self.assertEqual
numeric_literal
tests/db/fields/test_uniq_field_mixin_compat.py
test__get_fields_returns_correct_fields
UniqFieldMixinCompatTestCase
79
null
django-extensions/django-extensions
from unittest import mock import os from io import StringIO from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase DefaultCacheMock = mock.Mock() OtherCacheMock = mock.Mock() class ClearCacheTests(TestCase): def setUp(self): s...
self.out.getvalue())
self.assertIn
func_call
tests/management/commands/test_clear_cache.py
test_called_with_explicit_all
ClearCacheTests
53
null
django-extensions/django-extensions
from django.test import TestCase from django.template import Context, Template class TemplateRenderingTests(TestCase): def setUp(self): self.ctx = Context( { "worldvar": "world", } ) def test_simple_template(self): self.assertEqual(Template("hel...
"hello world")
self.assertEqual
string_literal
tests/test_template_rendering.py
test_simple_template
TemplateRenderingTests
14
null