Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions tests/test_annotations.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class C:
assert 1 == len(attr.fields(C))
assert_init_annotations(C, x=typing.List[int])

@pytest.mark.skipif(
sys.version_info[:2] < (3, 11),
reason="Incompatible behavior on older Pythons",
)
@pytest.mark.parametrize("slots", [True, False])
def test_auto_attribs(self, slots):
"""
Expand Down Expand Up @@ -149,7 +153,7 @@ class C:
x=typing.List[int],
y=int,
z=int,
foo=typing.Optional[typing.Any],
foo=typing.Any,
)

@pytest.mark.parametrize("slots", [True, False])
Expand Down Expand Up @@ -384,8 +388,9 @@ def noop():

assert attr.converters.optional(noop).__annotations__ == {}

@pytest.mark.xfail(
sys.version_info[:2] == (3, 6), reason="Does not work on 3.6."
@pytest.mark.skipif(
sys.version_info[:2] < (3, 11),
reason="Incompatible behavior on older Pythons",
)
@pytest.mark.parametrize("slots", [True, False])
def test_annotations_strings(self, slots):
Expand Down Expand Up @@ -417,7 +422,7 @@ class C:
x=typing.List[int],
y=int,
z=int,
foo=typing.Optional[typing.Any],
foo=typing.Any,
)

@pytest.mark.parametrize("slots", [True, False])
Expand Down
20 changes: 12 additions & 8 deletions tests/test_slots.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,10 +660,12 @@ 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)
assert None is getattr(i, "__setstate__", None)
assert getattr(object, "__getstate__", None) == getattr(
Comment thread
Tinche marked this conversation as resolved.
Outdated
C1, "__getstate__", None
)
assert getattr(object, "__setstate__", None) == getattr(
C1, "__setstate__", None
)

def test_no_getstate_setstate_if_option_false(self):
"""
Expand All @@ -674,10 +676,12 @@ def test_no_getstate_setstate_if_option_false(self):
class C:
x = attr.ib()

i = C(42)

assert None is getattr(i, "__getstate__", None)
assert None is getattr(i, "__setstate__", None)
assert getattr(object, "__getstate__", None) == getattr(
C, "__getstate__", None
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above

)
assert getattr(object, "__setstate__", None) == getattr(
C, "__setstate__", None
)

@pytest.mark.parametrize("cls", [C2(1), C2Slots(1)])
def test_getstate_set_state_force_true(self, cls):
Expand Down