no previously-included directories found matching 'docs/_build' py311 inst-nodeps: /tmp/attrs/.tox/.tmp/package/1/attrs-22.1.0.dev0.tar.gz py311 installed: attrs @ file:///tmp/attrs/.tox/.tmp/package/1/attrs-22.1.0.dev0.tar.gz,chevron==0.14.0,cloudpickle==2.0.0,coverage==6.3.2,decorator==5.1.1,hypothesis==6.46.2,iniconfig==1.1.1,mypy==0.950,mypy-extensions==0.4.3,packaging==21.3,pluggy==1.0.0,py==1.11.0,Pympler==1.0.1,pyparsing==3.0.8,pytest==7.1.2,pytest-mypy-plugins==1.9.3,PyYAML==6.0,regex==2022.4.24,sortedcontainers==2.4.0,tomli==2.0.1,typing_extensions==4.2.0,zope.interface==5.4.0 py311 run-test-pre: PYTHONHASHSEED='2329055761' py311 run-test: commands[0] | python -m pytest ============================= test session starts ============================== platform linux -- Python 3.11.0b1, pytest-7.1.2, pluggy-1.0.0 cachedir: .tox/py311/.pytest_cache rootdir: /tmp/attrs, configfile: tox.ini, testpaths: tests plugins: mypy-plugins-1.9.3, hypothesis-6.46.2 collected 1288 items tests/test_3rd_party.py F [ 0%] tests/test_annotations.py ....FF...............FF....................... [ 3%] [ 3%] tests/test_cmp.py ...................................................... [ 7%] ........................ [ 9%] tests/test_compat.py .. [ 9%] tests/test_config.py .... [ 10%] tests/test_converters.py ...................... [ 11%] tests/test_dunders.py .................................................. [ 15%] ............................................... [ 19%] tests/test_filters.py ................. [ 20%] tests/test_funcs.py ........................................... [ 24%] tests/test_functional.py ............................................... [ 27%] ........................................................................ [ 33%] ........................................................................ [ 38%] ........................................................................ [ 44%] ........................................................................ [ 50%] ................................................................... [ 55%] tests/test_hooks.py ......... [ 55%] tests/test_import.py . [ 56%] tests/test_init_subclass.py F.. [ 56%] tests/test_make.py ..................................................... [ 60%] ........................................................................ [ 65%] ........................................................................ [ 71%] ........................................FFs....... [ 75%] tests/test_mypy.yml .................................................... [ 79%] ............................ [ 81%] tests/test_next_gen.py ............................ [ 83%] tests/test_pattern_matching.py ..... [ 84%] tests/test_pyright.py s [ 84%] tests/test_setattr.py ..................x................. [ 87%] tests/test_slots.py ........FFF.s.s..........FF..FF [ 89%] tests/test_validators.py ............................................... [ 93%] ........................................................................ [ 98%] .......... [ 99%] tests/test_version_info.py ...... [100%] =================================== FAILURES =================================== _______________________ TestCloudpickleCompat.test_repr ________________________ self = @given(simple_classes()) > def test_repr(self, cls): tests/test_3rd_party.py:23: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ tests/test_3rd_party.py:30: in test_repr pkl = cloudpickle.dumps(inst) .tox/py311/lib/python3.11/site-packages/cloudpickle/cloudpickle_fast.py:73: in dumps cp.dump(obj) .tox/py311/lib/python3.11/site-packages/cloudpickle/cloudpickle_fast.py:602: in dump return Pickler.dump(self, obj) .tox/py311/lib/python3.11/site-packages/cloudpickle/cloudpickle_fast.py:692: in reducer_override return self._function_reduce(obj) .tox/py311/lib/python3.11/site-packages/cloudpickle/cloudpickle_fast.py:565: in _function_reduce return self._dynamic_function_reduce(obj) .tox/py311/lib/python3.11/site-packages/cloudpickle/cloudpickle_fast.py:546: in _dynamic_function_reduce state = _function_getstate(func) .tox/py311/lib/python3.11/site-packages/cloudpickle/cloudpickle_fast.py:157: in _function_getstate f_globals_ref = _extract_code_globals(func.__code__) .tox/py311/lib/python3.11/site-packages/cloudpickle/cloudpickle.py:334: in _extract_code_globals out_names = {names[oparg]: None for _, oparg in _walk_global_ops(co)} _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .0 = > out_names = {names[oparg]: None for _, oparg in _walk_global_ops(co)} E IndexError: tuple index out of range .tox/py311/lib/python3.11/site-packages/cloudpickle/cloudpickle.py:334: IndexError ---------------------------------- Hypothesis ---------------------------------- Falsifying example: test_repr( cls=tests.strategies.HypClass, self=, ) ___________________ TestAnnotations.test_auto_attribs[True] ____________________ self = slots = True @pytest.mark.parametrize("slots", [True, False]) def test_auto_attribs(self, slots): """ If *auto_attribs* is True, bare annotations are collected too. Defaults work and class variables are ignored. """ @attr.s(auto_attribs=True, slots=slots) class C: cls_var: typing.ClassVar[int] = 23 a: int x: typing.List[int] = attr.Factory(list) y: int = 2 z: int = attr.ib(default=3) foo: typing.Any = None i = C(42) assert "C(a=42, x=[], y=2, z=3, foo=None)" == repr(i) attr_names = {a.name for a in C.__attrs_attrs__} assert "a" in attr_names # just double check that the set works assert "cls_var" not in attr_names attr.resolve_types(C) assert int == attr.fields(C).a.type assert attr.Factory(list) == attr.fields(C).x.default assert typing.List[int] == attr.fields(C).x.type assert int == attr.fields(C).y.type assert 2 == attr.fields(C).y.default assert int == attr.fields(C).z.type assert typing.Any == attr.fields(C).foo.type # Class body is clean. if slots is False: with pytest.raises(AttributeError): C.y assert 2 == i.y else: assert isinstance(C.y, types.MemberDescriptorType) i.y = 23 assert 23 == i.y > assert_init_annotations( C, a=int, x=typing.List[int], y=int, z=int, foo=typing.Optional[typing.Any], ) E AssertionError: assert {'a': slots = False @pytest.mark.parametrize("slots", [True, False]) def test_auto_attribs(self, slots): """ If *auto_attribs* is True, bare annotations are collected too. Defaults work and class variables are ignored. """ @attr.s(auto_attribs=True, slots=slots) class C: cls_var: typing.ClassVar[int] = 23 a: int x: typing.List[int] = attr.Factory(list) y: int = 2 z: int = attr.ib(default=3) foo: typing.Any = None i = C(42) assert "C(a=42, x=[], y=2, z=3, foo=None)" == repr(i) attr_names = {a.name for a in C.__attrs_attrs__} assert "a" in attr_names # just double check that the set works assert "cls_var" not in attr_names attr.resolve_types(C) assert int == attr.fields(C).a.type assert attr.Factory(list) == attr.fields(C).x.default assert typing.List[int] == attr.fields(C).x.type assert int == attr.fields(C).y.type assert 2 == attr.fields(C).y.default assert int == attr.fields(C).z.type assert typing.Any == attr.fields(C).foo.type # Class body is clean. if slots is False: with pytest.raises(AttributeError): C.y assert 2 == i.y else: assert isinstance(C.y, types.MemberDescriptorType) i.y = 23 assert 23 == i.y > assert_init_annotations( C, a=int, x=typing.List[int], y=int, z=int, foo=typing.Optional[typing.Any], ) E AssertionError: assert {'a': slots = True @pytest.mark.xfail( sys.version_info[:2] == (3, 6), reason="Does not work on 3.6." ) @pytest.mark.parametrize("slots", [True, False]) def test_annotations_strings(self, slots): """ String annotations are passed into __init__ as is. It fails on 3.6 due to a bug in Python. """ import typing as t from typing import ClassVar @attr.s(auto_attribs=True, slots=slots) class C: cls_var1: "typing.ClassVar[int]" = 23 cls_var2: "ClassVar[int]" = 23 cls_var3: "t.ClassVar[int]" = 23 a: "int" x: "typing.List[int]" = attr.Factory(list) y: "int" = 2 z: "int" = attr.ib(default=3) foo: "typing.Any" = None attr.resolve_types(C, locals(), globals()) > assert_init_annotations( C, a=int, x=typing.List[int], y=int, z=int, foo=typing.Optional[typing.Any], ) E AssertionError: assert {'a': slots = False @pytest.mark.xfail( sys.version_info[:2] == (3, 6), reason="Does not work on 3.6." ) @pytest.mark.parametrize("slots", [True, False]) def test_annotations_strings(self, slots): """ String annotations are passed into __init__ as is. It fails on 3.6 due to a bug in Python. """ import typing as t from typing import ClassVar @attr.s(auto_attribs=True, slots=slots) class C: cls_var1: "typing.ClassVar[int]" = 23 cls_var2: "ClassVar[int]" = 23 cls_var3: "t.ClassVar[int]" = 23 a: "int" x: "typing.List[int]" = attr.Factory(list) y: "int" = 2 z: "int" = attr.ib(default=3) foo: "typing.Any" = None attr.resolve_types(C, locals(), globals()) > assert_init_annotations( C, a=int, x=typing.List[int], y=int, z=int, foo=typing.Optional[typing.Any], ) E AssertionError: assert {'a': class Vanilla(Base, param="foo"): tests/test_init_subclass.py:27: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ cls = .Vanilla'> param = 'foo', kw = {} def __init_subclass__(cls, param, **kw): > super().__init_subclass__(**kw) E TypeError: super(type, obj): obj must be an instance or subtype of type tests/test_init_subclass.py:24: TypeError _____________ TestAutoDetect.test_detects_setstate_getstate[True] ______________ self = , slots = True @pytest.mark.parametrize("slots", [True, False]) def test_detects_setstate_getstate(self, slots): """ __getstate__ and __setstate__ are not overwritten if either is present. """ @attr.s(slots=slots, auto_detect=True) class C: def __getstate__(self): return ("hi",) assert None is getattr(C(), "__setstate__", None) @attr.s(slots=slots, auto_detect=True) class C: called = attr.ib(False) def __setstate__(self, state): self.called = True i = C() assert False is i.called i.__setstate__(()) assert True is i.called > assert None is getattr(C(), "__getstate__", None) E AssertionError: assert None is E + where = getattr(C(called=False), '__getstate__', None) E + where C(called=False) = .C'>() tests/test_make.py:2294: AssertionError _____________ TestAutoDetect.test_detects_setstate_getstate[False] _____________ self = , slots = False @pytest.mark.parametrize("slots", [True, False]) def test_detects_setstate_getstate(self, slots): """ __getstate__ and __setstate__ are not overwritten if either is present. """ @attr.s(slots=slots, auto_detect=True) class C: def __getstate__(self): return ("hi",) assert None is getattr(C(), "__setstate__", None) @attr.s(slots=slots, auto_detect=True) class C: called = attr.ib(False) def __setstate__(self, state): self.called = True i = C() assert False is i.called i.__setstate__(()) assert True is i.called > assert None is getattr(C(), "__getstate__", None) E AssertionError: assert None is E + where = getattr(C(called=False), '__getstate__', None) E + where C(called=False) = .C'>() tests/test_make.py:2294: AssertionError _____________ TestClosureCellRewriting.test_closure_cell_rewriting _____________ self = def test_closure_cell_rewriting(self): """ Slotted classes support proper closure cell rewriting. This affects features like `__class__` and the no-arg super(). """ non_slot_instance = C1(x=1, y="test") slot_instance = C1Slots(x=1, y="test") assert non_slot_instance.my_class() is C1 > assert slot_instance.my_class() is C1Slots E AssertionError: assert is C1Slots E + where = () E + where = C1Slots(x=1, y='test').my_class tests/test_slots.py:419: AssertionError __________________ TestClosureCellRewriting.test_inheritance ___________________ self = def test_inheritance(self): """ Slotted classes support proper closure cell rewriting when inheriting. This affects features like `__class__` and the no-arg super(). """ @attr.s class C2(C1): def my_subclass(self): return __class__ @attr.s class C2Slots(C1Slots): def my_subclass(self): return __class__ non_slot_instance = C2(x=1, y="test") slot_instance = C2Slots(x=1, y="test") assert non_slot_instance.my_class() is C1 > assert slot_instance.my_class() is C1Slots E AssertionError: assert is C1Slots E + where = () E + where = C2Slots(x=1, y='test').my_class tests/test_slots.py:446: AssertionError ________________ TestClosureCellRewriting.test_cls_static[True] ________________ self = slots = True @pytest.mark.parametrize("slots", [True, False]) def test_cls_static(self, slots): """ Slotted classes support proper closure cell rewriting for class- and static methods. """ # Python can reuse closure cells, so we create new classes just for # this test. @attr.s(slots=slots) class C: @classmethod def clsmethod(cls): return __class__ > assert C.clsmethod() is C E AssertionError: assert .C'> is .C'> E + where .C'> = .C.clsmethod of .C'>>() E + where .C.clsmethod of .C'>> = .C'>.clsmethod tests/test_slots.py:470: AssertionError ____________ TestPickle.test_no_getstate_setstate_for_dict_classes _____________ self = def test_no_getstate_setstate_for_dict_classes(self): """ As long as getstate_setstate is None, nothing is done to dict classes. """ i = C1(1, 2) > assert None is getattr(i, "__getstate__", None) E AssertionError: assert None is E + where = getattr(C1(x=1, y=2), '__getstate__', None) tests/test_slots.py:665: AssertionError _____________ TestPickle.test_no_getstate_setstate_if_option_false _____________ self = def test_no_getstate_setstate_if_option_false(self): """ Don't add getstate/setstate if getstate_setstate is False. """ @attr.s(slots=True, getstate_setstate=False) class C: x = attr.ib() i = C(42) > assert None is getattr(i, "__getstate__", None) E AssertionError: assert None is E + where = getattr(C(x=42), '__getstate__', None) tests/test_slots.py:679: AssertionError ________________________ test_slots_super_property_get _________________________ def test_slots_super_property_get(): """ Both `super()` and `super(self.__class__, self)` work. """ @attr.s(slots=True) class A: x = attr.ib() @property def f(self): return self.x @attr.s(slots=True) class B(A): @property def f(self): return super().f ** 2 @attr.s(slots=True) class C(A): @property def f(self): return super(C, self).f ** 2 > assert B(11).f == 121 tests/test_slots.py:716: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = B(x=11) @property def f(self): > return super().f ** 2 E TypeError: super(type, obj): obj must be an instance or subtype of type tests/test_slots.py:708: TypeError ____________________ test_slots_super_property_get_shortcut ____________________ def test_slots_super_property_get_shortcut(): """ On Python 3, the `super()` shortcut is allowed. """ @attr.s(slots=True) class A: x = attr.ib() @property def f(self): return self.x @attr.s(slots=True) class B(A): @property def f(self): return super().f ** 2 > assert B(11).f == 121 tests/test_slots.py:741: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = B(x=11) @property def f(self): > return super().f ** 2 E TypeError: super(type, obj): obj must be an instance or subtype of type tests/test_slots.py:739: TypeError =============================== warnings summary =============================== .tox/py311/lib/python3.11/site-packages/attr/_make.py:891 tests/test_init_subclass.py::test_init_subclass_vanilla[True] tests/test_slots.py::TestClosureCellRewriting::test_cls_static[True] tests/test_slots.py::test_slots_empty_cell tests/test_slots.py::test_slots_super_property_get tests/test_slots.py::test_slots_super_property_get_shortcut /tmp/attrs/.tox/py311/lib/python3.11/site-packages/attr/_make.py:891: RuntimeWarning: Running interpreter doesn't sufficiently support code object introspection. Some features like bare super() or accessing __class__ will not work with slotted classes. set_closure_cell(cell, cls) -- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html =========================== short test summary info ============================ SKIPPED [1] tests/test_make.py:2296: Pre-3.10 only. SKIPPED [1] tests/test_pyright.py:26: Requires pyright. SKIPPED [1] tests/test_slots.py:480: can't break CodeType.replace() via monkeypatch SKIPPED [1] tests/test_slots.py:527: slots without weakref_slot should only work on PyPy XFAIL tests/test_setattr.py::TestSetAttr::test_slotted_confused FAILED tests/test_3rd_party.py::TestCloudpickleCompat::test_repr - IndexError... FAILED tests/test_annotations.py::TestAnnotations::test_auto_attribs[True] - ... FAILED tests/test_annotations.py::TestAnnotations::test_auto_attribs[False] FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[True] FAILED tests/test_annotations.py::TestAnnotations::test_annotations_strings[False] FAILED tests/test_init_subclass.py::test_init_subclass_vanilla[True] - TypeEr... FAILED tests/test_make.py::TestAutoDetect::test_detects_setstate_getstate[True] FAILED tests/test_make.py::TestAutoDetect::test_detects_setstate_getstate[False] FAILED tests/test_slots.py::TestClosureCellRewriting::test_closure_cell_rewriting FAILED tests/test_slots.py::TestClosureCellRewriting::test_inheritance - Asse... FAILED tests/test_slots.py::TestClosureCellRewriting::test_cls_static[True] FAILED tests/test_slots.py::TestPickle::test_no_getstate_setstate_for_dict_classes FAILED tests/test_slots.py::TestPickle::test_no_getstate_setstate_if_option_false FAILED tests/test_slots.py::test_slots_super_property_get - TypeError: super(... FAILED tests/test_slots.py::test_slots_super_property_get_shortcut - TypeErro... = 15 failed, 1268 passed, 4 skipped, 1 xfailed, 6 warnings in 104.50s (0:01:44) = ERROR: InvocationError for command /tmp/attrs/.tox/py311/bin/python -m pytest (exited with code 1) ___________________________________ summary ____________________________________ ERROR: py311: commands failed