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 |
|---|---|---|---|---|---|---|---|---|---|
AnonymouX47/term-image | from typing import Any
import pytest
from term_image.geometry import Size
from term_image.renderable import (
ArgsNamespace,
DataNamespace,
Frame,
IncompatibleArgsNamespaceError,
IncompatibleRenderArgsError,
NoArgsNamespaceError,
NoDataNamespaceError,
Renderable,
RenderArgs,
Re... | "FOO" | assert | string_literal | tests/renderable/test_types.py | test_getattr | TestArgsNamespace | 1,068 | null |
AnonymouX47/term-image | import pytest
from term_image.geometry import RawSize, Size
class TestNew:
@pytest.mark.parametrize("size", [(1, 10), (0, 1), (0, 0), (-1, 0), (-10, -1)])
def test_equal_to_normally_constructed(self, size):
assert RawSize._new(*size) == | RawSize(*size) | assert | func_call | tests/test_geometry.py | test_equal_to_normally_constructed | TestNew | 35 | null |
AnonymouX47/term-image | from term_image._ctlseqs import SGR_BG_DIRECT, SGR_DEFAULT
from term_image.image import BlockImage
from term_image.image.common import _ALPHA_THRESHOLD
from .. import set_fg_bg_colors
from . import common
from .common import _size, setup_common
class TestRender:
trans = BlockImage.from_file("tests/images/trans.p... | f"{self.trans:1.1#00ff00}" | assert | string_literal | tests/test_image/test_block.py | test_background_colour | TestRender | 73 | null |
AnonymouX47/term-image | import gc
import pytest
import urwid
from PIL import Image
from term_image import _ctlseqs as ctlseqs
from term_image.exceptions import RenderError, UrwidImageError
from term_image.image import (
BlockImage,
GraphicsImage,
ITerm2Image,
KittyImage,
Size,
TextImage,
)
from term_image.image.commo... | 5 | assert | numeric_literal | tests/widget/urwid/test_main.py | test_alloc | TestZIndex | 321 | null |
AnonymouX47/term-image | import pytest
from term_image.color import Color
class TestColor:
@pytest.mark.parametrize(
"rgba,hex",
[
((0, 0, 0, 0), "#00000000"),
((0, 10, 127, 255), "#000a7fff"),
((255, 255, 255, 255), "#ffffffff"),
],
)
def test_hex(self, rgba, hex):
... | hex | assert | variable | tests/test_color.py | test_hex | TestColor | 60 | null |
AnonymouX47/term-image | from typing import Any
import pytest
from term_image.geometry import Size
from term_image.renderable import (
ArgsNamespace,
DataNamespace,
Frame,
IncompatibleArgsNamespaceError,
IncompatibleRenderArgsError,
NoArgsNamespaceError,
NoDataNamespaceError,
Renderable,
RenderArgs,
Re... | set() | assert | func_call | tests/renderable/test_types.py | test_base | TestRenderArgs | 349 | null |
AnonymouX47/term-image | import os
import pytest
from term_image._ctlseqs import CURSOR_FORWARD
from term_image.geometry import RawSize, Size
from term_image.padding import (
AlignedPadding,
ExactPadding,
HAlign,
Padding,
RelativePaddingDimensionError,
VAlign,
)
class TestAlignedPadding:
@pytest.mark.parametrize... | height | assert | variable | tests/test_padding.py | test_height | TestAlignedPadding | 148 | null |
AnonymouX47/term-image | import atexit
import os
import pytest
from PIL import Image, UnidentifiedImageError
from term_image.exceptions import URLNotFoundError
from term_image.image import BaseImage, BlockImage, ImageSource, Size, from_url
python_image = "tests/images/python.png"
python_url = (
"https://raw.githubusercontent.com/Anonymo... | AttributeError) | pytest.raises | variable | tests/test_image/test_url.py | test_close | 58 | null | |
AnonymouX47/term-image | import pytest
from term_image.color import Color
class TestColor:
def test_a_default(self):
color = Color(0, 0, 0)
assert color.a == | 255 | assert | numeric_literal | tests/test_color.py | test_a_default | TestColor | 38 | null |
AnonymouX47/term-image | from operator import truediv
import pytest
from term_image import (
AutoCellRatio,
disable_queries,
disable_win_size_swap,
enable_queries,
enable_win_size_swap,
get_cell_ratio,
set_cell_ratio,
set_query_timeout,
utils,
)
from term_image.exceptions import TermImageError
from term_im... | 5 / 5 | assert | complex_expr | tests/test_top_level.py | test_dynamic | TestAuto | 71 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_frozen_attribute(self):
"""
Frozen attributes raise FrozenAttributeError, others are not affected.
... | pf.y | assert | complex_expr | tests/test_setattr.py | test_frozen_attribute | TestSetAttr | 65 | null |
python-attrs/attrs | import pytest
from attr import _config
class TestConfig:
def test_wrong_type(self):
"""
Passing anything else than a boolean raises TypeError.
"""
with pytest.raises( | TypeError) | pytest.raises | variable | tests/test_config.py | test_wrong_type | TestConfig | 41 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_change(self):
"""
The return value of a hook overwrites the value. But they are not run
on __i... | h.y | assert | complex_expr | tests/test_setattr.py | test_change | TestSetAttr | 43 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
@pytest.mark.parametrize("a_slots", [True, False])
@pytest.mark.parametrize("b_slots", [True, False])
@pytest.mark.par... | True | assert | bool_literal | tests/test_setattr.py | test_setattr_inherited_do_not_reset_intermediate | TestSetAttr | 423 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_pipe(self):
"""
Multiple hooks are possible, in that case the last return value is
used. They... | p.x1 | assert | complex_expr | tests/test_setattr.py | test_pipe | TestSetAttr | 140 | null |
python-attrs/attrs | import re
import pytest
import attr
from attr import _config, fields, has
from attr import validators as validator_module
from attr.validators import (
_subclass_of,
and_,
deep_iterable,
deep_mapping,
ge,
gt,
in_,
instance_of,
is_callable,
le,
lt,
matches_re,
max_l... | repr(v) | assert | func_call | tests/test_validators.py | test_repr | TestInstanceOf | 147 | null |
python-attrs/attrs | import sys
import types
import typing
import pytest
import attr
import attrs
from attr._make import _is_class_var
from attr.exceptions import UnannotatedAttributeError
def assert_init_annotations(cls, **annotations):
"""
Assert cls.__init__ has the correct annotations.
"""
__tracebackhide__ = True
... | 0 | assert | numeric_literal | tests/test_annotations.py | test_keyword_only_auto_attribs | TestAnnotations | 455 | null |
python-attrs/attrs | import pytest
import attr
class TestPatternMatching:
@pytest.mark.parametrize("dec", [attr.s, attr.define, attr.frozen])
def test_simple_match_case(self, dec):
"""
Simple match case statement works as expected with all class
decorators.
"""
@dec
class C:
... | C.__match_args__ | assert | complex_expr | tests/test_pattern_matching.py | test_simple_match_case | TestPatternMatching | 24 | null |
python-attrs/attrs | import pytest
from attr._cmp import cmp_using
from attr._compat import PY_3_13_PLUS
EqCSameType = cmp_using(eq=lambda a, b: a == b, class_name="EqCSameType")
PartialOrderCSameType = cmp_using(
eq=lambda a, b: a == b,
lt=lambda a, b: a < b,
class_name="PartialOrderCSameType",
)
FullOrderCSameType = cmp_usi... | "__ne__" | assert | string_literal | tests/test_cmp.py | test_ne | TestDundersUnnamedClass | 333 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_setattr_auto_detect_if_no_custom_setattr(self, slots):
"""
It's possible to remove the on_setattr hoo... | i.x | assert | complex_expr | tests/test_setattr.py | test_setattr_auto_detect_if_no_custom_setattr | TestSetAttr | 349 | null |
python-attrs/attrs | import pytest
from attr import VersionInfo
def _vi():
return VersionInfo(19, 2, 0, "final")
class TestVersionInfo:
def test_hash(self, vi):
"""
Same values, same hash.
"""
assert hash(vi) == | hash(VersionInfo(19, 2, 0, "final")) | assert | func_call | tests/test_version_info.py | test_hash | TestVersionInfo | 63 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | C(2, 2) | assert | func_call | tests/test_dunders.py | test_eq_ignore_attrib | TestEqOrder | 134 | null |
python-attrs/attrs | from __future__ import annotations
from datetime import datetime
import pytest
import attr
class TestTransformHook:
def hook(cls, attribs):
assert ["x", "y"] == | [a.name for a in attribs] | assert | collection | tests/test_hooks.py | hook | TestTransformHook | 190 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | i.c | assert | complex_expr | tests/test_dunders.py | test_default | TestAddInit | 825 | null |
python-attrs/attrs | import types
from typing import Protocol
import pytest
import attr
def _mp():
return types.MappingProxyType({"x": 42, "y": "foo"})
class TestMetadataProxy:
def test_immutable(self, mp):
"""
All mutating methods raise errors.
"""
with pytest.raises(TypeError, match="not supp... | AttributeError, match="no attribute 'clear'") | pytest.raises | complex_expr | tests/test_compat.py | test_immutable | TestMetadataProxy | 46 | null |
python-attrs/attrs | import pytest
from attr._cmp import cmp_using
from attr._compat import PY_3_13_PLUS
EqCSameType = cmp_using(eq=lambda a, b: a == b, class_name="EqCSameType")
PartialOrderCSameType = cmp_using(
eq=lambda a, b: a == b,
lt=lambda a, b: a < b,
class_name="PartialOrderCSameType",
)
FullOrderCSameType = cmp_usi... | C(2) | assert | func_call | tests/test_cmp.py | test_not_implemented_is_propagated | TestNotImplementedIsPropagated | 366 | null |
python-attrs/attrs | import re
from collections import OrderedDict
from typing import Generic, NamedTuple, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exce... | v | assert | variable | tests/test_funcs.py | test_change | TestAssoc | 627 | null |
python-attrs/attrs | import re
from collections import OrderedDict
from typing import Generic, NamedTuple, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exce... | d | assert | variable | tests/test_funcs.py | test_sets_no_retain | TestAsDict | 182 | null |
python-attrs/attrs | from importlib import metadata
import pytest
import attr
import attrs
def _mod(request):
return request.param
class TestLegacyMetadataHack:
def test_version(self, mod, recwarn):
"""
__version__ returns the correct version and doesn't warn.
"""
assert metadata.version("attrs"... | mod.__version__ | assert | complex_expr | tests/test_packaging.py | test_version | TestLegacyMetadataHack | 22 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_mro_ng(self):
"""
Attributes and methods... | d.xx() | assert | func_call | tests/test_next_gen.py | test_mro_ng | TestNextGen | 427 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_no_slots(self):
"""
slots can be deactiv... | ns.__dict__ | assert | complex_expr | tests/test_next_gen.py | test_no_slots | TestNextGen | 55 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_override_auto_attribs_false(self):
"""
D... | NoFields() | assert | func_call | tests/test_next_gen.py | test_override_auto_attribs_false | TestNextGen | 112 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_no_order(self):
"""
Order is off by defa... | TypeError) | pytest.raises | variable | tests/test_next_gen.py | test_no_order | TestNextGen | 78 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | i.x | assert | complex_expr | tests/test_dunders.py | test_factory_takes_self | TestAddInit | 862 | null |
python-attrs/attrs | import copy
import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._compat import PY_3_13_PLUS
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:... | 2 | assert | numeric_literal | tests/test_functional.py | test_subclassing_with_extra_attrs | TestFunctional | 229 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_pipe(self):
"""
Multiple hooks are possible, in that case the last return value is
used. They... | p.x2 | assert | complex_expr | tests/test_setattr.py | test_pipe | TestSetAttr | 141 | null |
python-attrs/attrs | import re
import pytest
import attr
from attr import _config, fields, has
from attr import validators as validator_module
from attr.validators import (
_subclass_of,
and_,
deep_iterable,
deep_mapping,
ge,
gt,
in_,
instance_of,
is_callable,
le,
lt,
matches_re,
max_l... | expected | assert | variable | tests/test_validators.py | test_set_validators_disabled | TestDisableValidators | 62 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import Converter, Factory, attrib
from attr._compat import _AnnotationExtractor
from attr.converters import default_if_none, optional, pipe, to_bool
class TestOptional:
def test_success_with_none(self):
"""
Nothing happens if None.
"""
... | None | assert | none_literal | tests/test_converters.py | test_success_with_none | TestOptional | 154 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | i | assert | variable | tests/test_dunders.py | test_hash_mirrors_eq | TestAddHash | 574 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_subclass_frozen(self):
"""
It's possible... | B(1, 2) | assert | func_call | tests/test_next_gen.py | test_subclass_frozen | TestNextGen | 255 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_exception(self):
"""
Exceptions are dete... | e.other | assert | complex_expr | tests/test_next_gen.py | test_exception | TestNextGen | 206 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | obj.b | assert | complex_expr | tests/test_dunders.py | test_sets_attributes | TestAddInit | 807 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import Converter, Factory, attrib
from attr._compat import _AnnotationExtractor
from attr.converters import default_if_none, optional, pipe, to_bool
class TestOptional:
def test_success_with_type(self):
"""
Wrapped converter is used as usual if ... | 42 | assert | numeric_literal | tests/test_converters.py | test_success_with_type | TestOptional | 146 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_converts_and_validates_by_default(self):
"""
... | inst.x | assert | complex_expr | tests/test_next_gen.py | test_converts_and_validates_by_default | TestNextGen | 390 | null |
python-attrs/attrs | import pytest
import attr
class TestPatternMatching:
def test_match_args_kw_only(self):
"""
kw_only classes don't generate __match_args__.
kw_only fields are not included in __match_args__.
"""
@attr.define
class C:
a = attr.field(kw_only=True)
... | TypeError, match=msg) | pytest.raises | complex_expr | tests/test_pattern_matching.py | test_match_args_kw_only | TestPatternMatching | 70 | null |
python-attrs/attrs | import pytest
from attr._cmp import cmp_using
from attr._compat import PY_3_13_PLUS
EqCSameType = cmp_using(eq=lambda a, b: a == b, class_name="EqCSameType")
PartialOrderCSameType = cmp_using(
eq=lambda a, b: a == b,
lt=lambda a, b: a < b,
class_name="PartialOrderCSameType",
)
FullOrderCSameType = cmp_usi... | cls(2) | assert | func_call | tests/test_cmp.py | test_unequal_same_type | TestEqOrder | 86 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | hash(i) | assert | func_call | tests/test_dunders.py | test_hash_mirrors_eq | TestAddHash | 575 | null |
python-attrs/attrs | from __future__ import annotations
from datetime import datetime
import pytest
import attr
class TestTransformHook:
def test_hook_add_field(self):
"""
It is possible to add fields via the hook.
"""
def hook(cls, attribs):
a1 = attribs[0]
a2 = a1.evolve(n... | attr.asdict(C(1, 2)) | assert | func_call | tests/test_hooks.py | test_hook_add_field | TestTransformHook | 104 | null |
python-attrs/attrs | import functools
import pickle
import weakref
from unittest import mock
import pytest
import attr
import attrs
from attr._compat import PY_3_14_PLUS, PYPY
def tests_weakref_does_not_add_when_inheriting_with_weakref():
"""
`weakref_slot=True` does not add a new __weakref__ slot when inheriting
one.
... | 2 | assert | numeric_literal | tests/test_slots.py | test_slots_cached_property_raising_attributeerror | 863 | null | |
python-attrs/attrs | from importlib import metadata
import pytest
import attr
import attrs
def _mod(request):
return request.param
class TestLegacyMetadataHack:
def test_does_not_exist(self, mod):
"""
Asking for unsupported dunders raises an AttributeError.
"""
with | AttributeError, match=f"module {mod.__name__} has no attribute __yolo__") | pytest.raises | complex_expr | tests/test_packaging.py | test_does_not_exist | TestLegacyMetadataHack | 30 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import Converter, Factory, attrib
from attr._compat import _AnnotationExtractor
from attr.converters import default_if_none, optional, pipe, to_bool
class TestConverter:
def test_falsey_converter(self):
"""
Passing a false-y instance still produ... | c.a | assert | complex_expr | tests/test_converters.py | test_falsey_converter | TestConverter | 132 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import Converter, Factory, attrib
from attr._compat import _AnnotationExtractor
from attr.converters import default_if_none, optional, pipe, to_bool
class TestOptionalPipe:
def test_instance(self):
"""
Should work when set as an attrib.
... | c2.x | assert | complex_expr | tests/test_converters.py | test_instance | TestOptionalPipe | 341 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | C(1) | assert | func_call | tests/test_dunders.py | test_hash_mirrors_eq | TestAddHash | 578 | null |
python-attrs/attrs | import re
import pytest
import attr
from attr import _config, fields, has
from attr import validators as validator_module
from attr.validators import (
_subclass_of,
and_,
deep_iterable,
deep_mapping,
ge,
gt,
in_,
instance_of,
is_callable,
le,
lt,
matches_re,
max_l... | False | assert | bool_literal | tests/test_validators.py | test_disabled_ctx | TestDisableValidators | 83 | null |
python-attrs/attrs | import copy
import functools
import gc
import inspect
import itertools
import sys
import unicodedata
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
impo... | 2 | assert | numeric_literal | tests/test_make.py | test_adds_keyword_only_arguments | TestKeywordOnlyAttributes | 992 | null |
python-attrs/attrs | import copy
import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._compat import PY_3_13_PLUS
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:... | e2 | assert | variable | tests/test_functional.py | test_auto_exc | TestFunctional | 591 | null |
python-attrs/attrs | import pytest
import attr
from attr import fields
from attr.filters import _split_what, exclude, include
class TestInclude:
@pytest.mark.parametrize(
("incl", "value"),
[
((int,), 42),
((str,), "hello"),
((str, fields(C).a), 42),
((str, fields(C).b... | True | assert | bool_literal | tests/test_filters.py | test_allow | TestInclude | 60 | null |
python-attrs/attrs | import re
import pytest
import attr
from attr import _config, fields, has
from attr import validators as validator_module
from attr.validators import (
_subclass_of,
and_,
deep_iterable,
deep_mapping,
ge,
gt,
in_,
instance_of,
is_callable,
le,
lt,
matches_re,
max_l... | TypeError) | pytest.raises | variable | tests/test_validators.py | test_fail | TestInstanceOf | 133 | null |
python-attrs/attrs | import re
from collections import OrderedDict
from typing import Generic, NamedTuple, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis import strategies as st
import attr
from attr import asdict, assoc, astuple, evolve, fields, has
from attr._compat import Mapping, Sequence
from attr.exce... | Int | assert | variable | tests/test_funcs.py | test_non_atomic_types | TestAsDict | 82 | null |
python-attrs/attrs | import pytest
from attr import VersionInfo
def _vi():
return VersionInfo(19, 2, 0, "final")
class TestVersionInfo:
@pytest.mark.parametrize("other", [(), (19, 2, 0, "final", "garbage")])
def test_wrong_len(self, vi, other):
"""
Comparing with a tuple that has the wrong length raises an e... | TypeError) | pytest.raises | variable | tests/test_version_info.py | test_wrong_len | TestVersionInfo | 37 | null |
python-attrs/attrs | import sys
import types
import typing
import pytest
import attr
import attrs
from attr._make import _is_class_var
from attr.exceptions import UnannotatedAttributeError
def assert_init_annotations(cls, **annotations):
"""
Assert cls.__init__ has the correct annotations.
"""
__tracebackhide__ = True
... | B) | assert_* | variable | tests/test_annotations.py | test_auto_attribs_subclassing | TestAnnotations | 200 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_no_validator_no_converter(self):
"""
validate and convert tolerate missing validators and converters.... | c.x | assert | complex_expr | tests/test_setattr.py | test_no_validator_no_converter | TestSetAttr | 173 | null |
python-attrs/attrs | import re
import pytest
import attr
from attr import _config, fields, has
from attr import validators as validator_module
from attr.validators import (
_subclass_of,
and_,
deep_iterable,
deep_mapping,
ge,
gt,
in_,
instance_of,
is_callable,
le,
lt,
matches_re,
max_l... | None | assert | none_literal | tests/test_validators.py | test_hashability | 854 | null | |
python-attrs/attrs | import copy
import functools
import gc
import inspect
import itertools
import sys
import unicodedata
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
impo... | 0 | assert | numeric_literal | tests/test_make.py | test_ignores_kw_only_when_init_is_false | TestKeywordOnlyAttributes | 1,008 | null |
python-attrs/attrs | import pytest
import attr
from attr import fields
from attr.filters import _split_what, exclude, include
class TestInclude:
@pytest.mark.parametrize(
("incl", "value"),
[
((str,), 42),
((int,), "hello"),
((str, fields(C).b), 42),
((int, fields(C).b... | False | assert | bool_literal | tests/test_filters.py | test_drop_class | TestInclude | 80 | null |
python-attrs/attrs | from __future__ import annotations
from datetime import datetime
import pytest
import attr
class TestTransformHook:
def test_hook_applied_modify_attrib(self):
"""
The transform hook can modify attributes.
"""
def hook(cls, attribs):
attr.resolve_types(cls, attribs=a... | c | assert | variable | tests/test_hooks.py | test_hook_applied_modify_attrib | TestTransformHook | 72 | null |
python-attrs/attrs | import re
import pytest
import attr
from attr import _config, fields, has
from attr import validators as validator_module
from attr.validators import (
_subclass_of,
and_,
deep_iterable,
deep_mapping,
ge,
gt,
in_,
instance_of,
is_callable,
le,
lt,
matches_re,
max_l... | True | assert | bool_literal | tests/test_validators.py | test_default | TestDisableValidators | 51 | null |
python-attrs/attrs | import sys
import types
import typing
import pytest
import attr
import attrs
from attr._make import _is_class_var
from attr.exceptions import UnannotatedAttributeError
def assert_init_annotations(cls, **annotations):
"""
Assert cls.__init__ has the correct annotations.
"""
__tracebackhide__ = True
... | {} | assert | collection | tests/test_annotations.py | test_pipe_non_introspectable | TestAnnotations | 323 | null |
python-attrs/attrs | import copy
import functools
import gc
import inspect
import itertools
import sys
import unicodedata
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
impo... | 4 | assert | numeric_literal | tests/test_make.py | test_adds_keyword_only_arguments | TestKeywordOnlyAttributes | 994 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | repr(i) | assert | func_call | tests/test_dunders.py | test_underscores | TestAddRepr | 408 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
@pytest.mark.parametrize(
"decorator",
[
... | None | assert | none_literal | tests/test_next_gen.py | test_discard_context | TestNextGen | 327 | null |
python-attrs/attrs | import pytest
from attr import VersionInfo
def _vi():
return VersionInfo(19, 2, 0, "final")
class TestVersionInfo:
def test_order(self, vi):
"""
Ordering works as expected.
"""
assert vi < (20,)
assert vi < (19, 2, 1)
assert vi > (0,)
assert vi <= | (19, 2) | assert | collection | tests/test_version_info.py | test_order | TestVersionInfo | 54 | null |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | add_str | assert | variable | tests/test_dunders.py | test_str | TestAddRepr | 433 | null |
python-attrs/attrs | from __future__ import annotations
from datetime import datetime
import pytest
import attr
class TestTransformHook:
def test_hook_generator(self):
"""
field_transfromers can be a generators.
Regression test for #1416.
"""
def hook(cls, attribs):
yield from ... | [a.name for a in attr.fields(Base)] | assert | collection | tests/test_hooks.py | test_hook_generator | TestTransformHook | 234 | null |
python-attrs/attrs | import types
from typing import Protocol
import pytest
import attr
def _mp():
return types.MappingProxyType({"x": 42, "y": "foo"})
class TestMetadataProxy:
def test_immutable(self, mp):
"""
All mutating methods raise errors.
"""
with pytest.raises( | TypeError, match="not support item assignment") | pytest.raises | complex_expr | tests/test_compat.py | test_immutable | TestMetadataProxy | 37 | null |
python-attrs/attrs | import pytest
import attr
from attr import fields
from attr.filters import _split_what, exclude, include
class TestSplitWhat:
def test_splits(self):
"""
Splits correctly.
"""
asser | _split_what((str, "123", fields(C).a, int, "abcd")) | assert | func_call | tests/test_filters.py | test_splits | TestSplitWhat | 30 | null |
python-attrs/attrs | import pytest
from attr import VersionInfo
def _vi():
return VersionInfo(19, 2, 0, "final")
class TestVersionInfo:
@pytest.mark.parametrize("other", [(), (19, 2, 0, "final", "garbage")])
def test_wrong_len(self, vi, other):
"""
Comparing with a tuple that has the wrong length raises an e... | other | assert | variable | tests/test_version_info.py | test_wrong_len | TestVersionInfo | 35 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import Converter, Factory, attrib
from attr._compat import _AnnotationExtractor
from attr.converters import default_if_none, optional, pipe, to_bool
class TestPipe:
def test_wrapped_annotation(self):
"""
The return type of the wrapped converter ... | i.x | assert | complex_expr | tests/test_converters.py | test_wrapped_annotation | TestPipe | 293 | null |
python-attrs/attrs | import pytest
from attr import _config
class TestConfig:
def test_default(self):
"""
Run validators by default.
"""
assert True is | _config._run_validators | assert | complex_expr | tests/test_config.py | test_default | TestConfig | 17 | null |
python-attrs/attrs | from __future__ import annotations
import json
import shutil
import subprocess
from pathlib import Path
import pytest
pytestmark = [
pytest.mark.skipif(
shutil.which("pyright") is None, reason="Requires pyright."
),
]
def parse_pyright_output(test_file: Path) -> set[tuple[str, str]]:
pyright = ... | expected_diagnostics | assert | variable | tests/test_pyright.py | test_pyright_attrsinstance_compat | 108 | null | |
python-attrs/attrs | import pytest
from attr._cmp import cmp_using
from attr._compat import PY_3_13_PLUS
EqCSameType = cmp_using(eq=lambda a, b: a == b, class_name="EqCSameType")
PartialOrderCSameType = cmp_using(
eq=lambda a, b: a == b,
lt=lambda a, b: a < b,
class_name="PartialOrderCSameType",
)
FullOrderCSameType = cmp_usi... | C(1) | assert | func_call | tests/test_cmp.py | test_not_implemented_is_propagated | TestNotImplementedIsPropagated | 367 | null |
python-attrs/attrs | from __future__ import annotations
from datetime import datetime
import pytest
import attr
class TestTransformHook:
def test_hook_reorder_fields_before_order_check(self):
"""
It is possible to reorder fields via the hook before order-based errors are raised.
Regression test for #1147.
... | attr.asdict(C(1)) | assert | func_call | tests/test_hooks.py | test_hook_reorder_fields_before_order_check | TestTransformHook | 154 | null |
python-attrs/attrs | import copy
import functools
import gc
import inspect
import itertools
import sys
import unicodedata
from operator import attrgetter
from typing import Generic, TypeVar
import pytest
from hypothesis import assume, given
from hypothesis.strategies import booleans, integers, lists, sampled_from, text
import attr
impo... | 1 | assert | numeric_literal | tests/test_make.py | test_kw_only | TestTransformAttrs | 271 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_no_order(self):
"""
Order is off by defa... | Ordered(2) | assert | func_call | tests/test_next_gen.py | test_no_order | TestNextGen | 85 | null |
python-attrs/attrs | import pytest
from attr._cmp import cmp_using
from attr._compat import PY_3_13_PLUS
EqCSameType = cmp_using(eq=lambda a, b: a == b, class_name="EqCSameType")
PartialOrderCSameType = cmp_using(
eq=lambda a, b: a == b,
lt=lambda a, b: a < b,
class_name="PartialOrderCSameType",
)
FullOrderCSameType = cmp_usi... | "__eq__" | assert | string_literal | tests/test_cmp.py | test_eq | TestDundersUnnamedClass | 322 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import setters
from attr.exceptions import FrozenAttributeError
from attr.validators import instance_of, matches_re
class TestSetAttr:
def test_change(self):
"""
The return value of a hook overwrites the value. But they are not run
on __i... | h.x | assert | complex_expr | tests/test_setattr.py | test_change | TestSetAttr | 42 | null |
python-attrs/attrs | import copy
import inspect
import pickle
from copy import deepcopy
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._compat import PY_3_13_PLUS
from attr._make import NOTHING, Attribute
from attr.exceptions import FrozenInstanceError
class TestFunctional:... | C() | assert | func_call | tests/test_functional.py | test_default_decorator | TestFunctional | 356 | null |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import Converter, Factory, attrib
from attr._compat import _AnnotationExtractor
from attr.converters import default_if_none, optional, pipe, to_bool
class TestPipe:
def test_empty(self):
"""
Empty pipe returns same value.
"""
o =... | pipe()(o) | assert | func_call | tests/test_converters.py | test_empty | TestPipe | 276 | null |
python-attrs/attrs | import pytest
import attr
class TestPatternMatching:
@pytest.mark.parametrize("dec", [attr.s, attr.define, attr.frozen])
def test_simple_match_case(self, dec):
"""
Simple match case statement works as expected with all class
decorators.
"""
@dec
class C:
... | a | assert | variable | tests/test_pattern_matching.py | test_simple_match_case | TestPatternMatching | 33 | null |
python-attrs/attrs | import pytest
from attr import VersionInfo
def _vi():
return VersionInfo(19, 2, 0, "final")
class TestVersionInfo:
def test_order(self, vi):
"""
Ordering works as expected.
"""
assert vi < | (20,) | assert | collection | tests/test_version_info.py | test_order | TestVersionInfo | 51 | null |
python-attrs/attrs | import pytest
from attr import _config
class TestConfig:
def test_get_run_validators(self):
"""
Returns `_run_validators`.
"""
_config._run_validators = False
assert _config._run_validators is | _config.get_run_validators() | assert | func_call | tests/test_config.py | test_get_run_validators | TestConfig | 33 | null |
python-attrs/attrs | from __future__ import annotations
import json
import shutil
import subprocess
from pathlib import Path
import pytest
pytestmark = [
pytest.mark.skipif(
shutil.which("pyright") is None, reason="Requires pyright."
),
]
def parse_pyright_output(test_file: Path) -> set[tuple[str, str]]:
pyright = ... | diagnostics | assert | variable | tests/test_pyright.py | test_pyright_baseline | 80 | null | |
python-attrs/attrs | import copy
import inspect
import pickle
import pytest
from hypothesis import given
from hypothesis.strategies import booleans
import attr
from attr._make import (
NOTHING,
Factory,
_add_repr,
_compile_and_eval,
_make_init_script,
fields,
make_class,
)
from attr.validators import instanc... | i.b | assert | complex_expr | tests/test_dunders.py | test_default | TestAddInit | 824 | null |
python-attrs/attrs | import sys
import types
import typing
import pytest
import attr
import attrs
from attr._make import _is_class_var
from attr.exceptions import UnannotatedAttributeError
def assert_init_annotations(cls, **annotations):
"""
Assert cls.__init__ has the correct annotations.
"""
__tracebackhide__ = True
... | C) | assert_* | variable | tests/test_annotations.py | test_basic_annotations | TestAnnotations | 51 | null |
python-attrs/attrs | import pytest
from attr import VersionInfo
def _vi():
return VersionInfo(19, 2, 0, "final")
class TestVersionInfo:
def test_order(self, vi):
"""
Ordering works as expected.
"""
assert vi < (20,)
assert vi < | (19, 2, 1) | assert | collection | tests/test_version_info.py | test_order | TestVersionInfo | 52 | null |
python-attrs/attrs | import re
from contextlib import contextmanager
from functools import partial
import pytest
import attr as _attr # don't use it by accident
import attrs
from attr._compat import PY_3_11_PLUS
from attr._make import ClassProps
class TestNextGen:
def test_auto_attribs_partially_annotated(self):
"""
... | 10 | assert | numeric_literal | tests/test_next_gen.py | test_auto_attribs_partially_annotated | TestNextGen | 168 | null |
python-attrs/attrs | import abc
import inspect
import pytest
import attrs
from attr._compat import PY_3_10_PLUS, PY_3_12_PLUS
class TestUpdateAbstractMethods:
def test_abc_implementation(self, slots):
"""
If an attrs class implements an abstract method, it stops being
abstract.
"""
class Ord... | Concrete(1) | assert | func_call | tests/test_abc.py | test_abc_implementation | TestUpdateAbstractMethods | 37 | null |
python-attrs/attrs | import types
from typing import Protocol
import pytest
import attr
def _mp():
return types.MappingProxyType({"x": 42, "y": "foo"})
class TestMetadataProxy:
def test_immutable(self, mp):
"""
All mutating methods raise errors.
"""
with pytest.raises(TypeError, match="not supp... | TypeError, match="not support item deletion") | pytest.raises | complex_expr | tests/test_compat.py | test_immutable | TestMetadataProxy | 40 | null |
python-attrs/attrs | from attrs import define, fields, resolve_types
def test_forward_class_reference():
"""
Class A can reference B even though it is defined later.
"""
@define
class A:
b: B
class B:
pass
resolve_types(A)
assert fields(A).b.type is | B | assert | variable | tests/test_forward_references.py | test_forward_class_reference | 22 | null | |
python-attrs/attrs | import pickle
import pytest
import attr
from attr import Converter, Factory, attrib
from attr._compat import _AnnotationExtractor
from attr.converters import default_if_none, optional, pipe, to_bool
class TestConverter:
def test_works_as_adapter(self):
"""
Converter instances work as adapters a... | taken | assert | variable | tests/test_converters.py | test_works_as_adapter | TestConverter | 79 | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.