Skip to content

Commit

Permalink
rm out-of-date test code/comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jab committed Dec 26, 2023
1 parent 3239a15 commit 646adfa
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 21 deletions.
1 change: 0 additions & 1 deletion tests/property_tests/_strategies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
6 changes: 2 additions & 4 deletions tests/property_tests/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion tests/property_tests/test_properties.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down
17 changes: 2 additions & 15 deletions tests/test_class_relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from __future__ import annotations

import sys
import typing as t
from collections import OrderedDict
from collections.abc import Hashable
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)


Expand Down Expand Up @@ -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)

0 comments on commit 646adfa

Please # to comment.