From 646adfab0321167c6cae6e962c909122d76c374a Mon Sep 17 00:00:00 2001 From: Joshua Bronson Date: Tue, 26 Dec 2023 15:09:05 -0500 Subject: [PATCH] rm out-of-date test code/comments --- tests/property_tests/_strategies.py | 1 - tests/property_tests/_types.py | 6 ++---- tests/property_tests/test_properties.py | 2 +- tests/test_class_relationships.py | 17 ++--------------- 4 files changed, 5 insertions(+), 21 deletions(-) diff --git a/tests/property_tests/_strategies.py b/tests/property_tests/_strategies.py index 098fd1e2..5d332130 100644 --- a/tests/property_tests/_strategies.py +++ b/tests/property_tests/_strategies.py @@ -98,7 +98,6 @@ def _bi_and_map(bi_types: t.Any, map_types: t.Any = MAPPING_TYPES, init_items: t BI_AND_MAP_FROM_SAME_ND_ITEMS = _bi_and_map(BIDICT_TYPES) -# Update the following when we drop support for Python < 3.8. On 3.8+, all mappings are reversible. RBI_AND_RMAP_FROM_SAME_ND_ITEMS = _bi_and_map(REVERSIBLE_BIDICT_TYPES, st.just(OrderedDict)) HBI_AND_HMAP_FROM_SAME_ND_ITEMS = _bi_and_map(FROZEN_BIDICT_TYPES, HASHABLE_MAPPING_TYPES) diff --git a/tests/property_tests/_types.py b/tests/property_tests/_types.py index 5a2ccd9e..c5c94a49 100644 --- a/tests/property_tests/_types.py +++ b/tests/property_tests/_types.py @@ -4,7 +4,7 @@ # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. -"""Types for Hypothoses tests.""" +"""Types for Hypothesis tests.""" from __future__ import annotations @@ -63,9 +63,7 @@ class UserBidictNotOwnInverse2(UserBidictNotOwnInverse[KT, VT]): ORDERED_BIDICT_TYPES: BiTypesT = (OrderedBidict, UserOrderedBidict) ORDER_PRESERVING_BIDICT_TYPES: BiTypesT = tuple(set(FROZEN_BIDICT_TYPES + ORDERED_BIDICT_TYPES)) BIDICT_TYPES: BiTypesT = tuple(set(MUTABLE_BIDICT_TYPES + FROZEN_BIDICT_TYPES + ORDERED_BIDICT_TYPES)) -# When support is dropped for Python < 3.8, all bidict types will be reversible, -# and we can remove the following and just use BIDICT_TYPES instead: -REVERSIBLE_BIDICT_TYPES: BiTypesT = tuple(b for b in BIDICT_TYPES if issubclass(b, t.Reversible)) +REVERSIBLE_BIDICT_TYPES: BiTypesT = tuple(set(BIDICT_TYPES) - {UserBidict, UserBidictNotOwnInverse}) BIDICT_TYPE_WHOSE_MODULE_HAS_REF_TO_INV_CLS = UserBidictNotOwnInverse BIDICT_TYPE_WHOSE_MODULE_HAS_NO_REF_TO_INV_CLS = UserBidictNotOwnInverse2 diff --git a/tests/property_tests/test_properties.py b/tests/property_tests/test_properties.py index 93844b6c..c5ab748f 100644 --- a/tests/property_tests/test_properties.py +++ b/tests/property_tests/test_properties.py @@ -312,7 +312,7 @@ def test_consistency_after_method_call(bi_and_cmp_dict: t.Any, data: t.Any) -> N assert collect(bi.inv.keys()) == collect(bi.inv) == vals assert collect(bi.inv.values()) == collect(bi.inv[k] for k in bi.inv) == keys assert collect(bi.inv.items()) == collect((k, bi.inv[k]) for k in bi.inv) - if not getattr(bi.keys(), '__reversed__', None): # Python < 3.8 + if not getattr(bi.keys(), '__reversed__', None): return assert collect(reversed(bi.keys())) == collect(reversed(bi.inv.values())) assert collect(reversed(bi.values())) == collect(reversed(bi.inv.keys())) diff --git a/tests/test_class_relationships.py b/tests/test_class_relationships.py index 53c60392..9deee4a3 100644 --- a/tests/test_class_relationships.py +++ b/tests/test_class_relationships.py @@ -8,7 +8,6 @@ from __future__ import annotations -import sys import typing as t from collections import OrderedDict from collections.abc import Hashable @@ -41,7 +40,6 @@ class AbstractBimap(BidirectionalMapping[t.Any, t.Any]): MUTABLE_BIDICT_TYPES = (bidict, OrderedBidict) HASHABLE_BIDICT_TYPES = (frozenbidict,) ORDERED_BIDICT_TYPES = (OrderedBidict,) -REVERSIBLE_BIDICT_TYPES = BIDICT_TYPES @pytest.mark.parametrize('bi_cls', BIMAP_TYPES) @@ -84,9 +82,9 @@ def test_issubclass_hashable(bi_cls: BiT) -> None: assert issubclass(bi_cls, Hashable) -@pytest.mark.parametrize('bi_cls', REVERSIBLE_BIDICT_TYPES) +@pytest.mark.parametrize('bi_cls', BIDICT_TYPES) def test_reversible(bi_cls: BiT) -> None: - """All bidict types should be reversible.""" + """All built-in bidict types should be reversible.""" assert issubclass(bi_cls, Reversible) @@ -133,14 +131,3 @@ def test_bidict_bases_init_succeed(bi_cls: BiT) -> None: """Bidict base classes should be initializable and have a working .inverse property.""" b = bi_cls(one=1, two=2) assert dict(b.inverse) == {1: 'one', 2: 'two'} - - -def test_bidict_reversible_matches_dict_reversible() -> None: - """Reversibility of bidict matches dict's on all supported Python versions.""" - assert issubclass(bidict, Reversible) == issubclass(dict, Reversible) - - -@pytest.mark.skipif(sys.version_info < (3, 8), reason='reversible unordered bidicts require Python 3.8+') -def test_bidict_reversible() -> None: - """All bidicts are Reversible on Python 3.8+.""" - assert issubclass(bidict, Reversible)