2021-12-27 08:29:09 +00:00
|
|
|
# SPDX-License-Identifier: MIT
|
|
|
|
|
2021-11-04 05:52:10 +00:00
|
|
|
"""
|
|
|
|
Tests for compatibility against other Python modules.
|
|
|
|
"""
|
|
|
|
|
2021-12-29 08:43:19 +00:00
|
|
|
import pytest
|
2021-11-04 05:52:10 +00:00
|
|
|
|
|
|
|
from hypothesis import given
|
|
|
|
|
2024-08-06 11:37:35 +00:00
|
|
|
from attr._compat import PY_3_14_PLUS
|
|
|
|
|
2021-11-04 05:52:10 +00:00
|
|
|
from .strategies import simple_classes
|
|
|
|
|
|
|
|
|
2021-12-29 08:43:19 +00:00
|
|
|
cloudpickle = pytest.importorskip("cloudpickle")
|
|
|
|
|
|
|
|
|
2024-08-06 11:37:35 +00:00
|
|
|
@pytest.mark.xfail(
|
|
|
|
PY_3_14_PLUS, reason="cloudpickle is currently broken on 3.14."
|
|
|
|
)
|
2022-03-21 07:47:47 +00:00
|
|
|
class TestCloudpickleCompat:
|
2021-11-04 05:52:10 +00:00
|
|
|
"""
|
|
|
|
Tests for compatibility with ``cloudpickle``.
|
|
|
|
"""
|
|
|
|
|
2023-12-08 18:24:25 +00:00
|
|
|
@given(simple_classes(cached_property=False))
|
2021-11-04 05:52:10 +00:00
|
|
|
def test_repr(self, cls):
|
|
|
|
"""
|
|
|
|
attrs instances can be pickled and un-pickled with cloudpickle.
|
|
|
|
"""
|
|
|
|
inst = cls()
|
|
|
|
# Exact values aren't a concern so long as neither direction
|
|
|
|
# raises an exception.
|
|
|
|
pkl = cloudpickle.dumps(inst)
|
|
|
|
cloudpickle.loads(pkl)
|