diff --git a/tests/hypothesis/_strategies.py b/tests/hypothesis/_strategies.py index 34268ae..5a13511 100644 --- a/tests/hypothesis/_strategies.py +++ b/tests/hypothesis/_strategies.py @@ -172,15 +172,19 @@ def _bidict_and_mapping_from_items( else: map_cls = draw(map_types) bi_items_ = draw(bi_items) - if map_items in (_SAME_AS_BI_ITEMS, _SAME_AS_BI_ITEMS_DIFF_ORDER): + same_items = map_items in (_SAME_AS_BI_ITEMS, _SAME_AS_BI_ITEMS_DIFF_ORDER) + if same_items: map_items_ = bi_items_[:] if map_items is _SAME_AS_BI_ITEMS_DIFF_ORDER: draw(RAND).shuffle(map_items_) assume(map_items_ != bi_items_) else: map_items_ = draw(map_items) - assume(map_items_ != bi_items_) - return bi_cls(bi_items_), map_cls(map_items_) + b = bi_cls(bi_items_) + m = map_cls(map_items_) + if not same_items: + assume(m.items() != b.items()) + return b, m BIDICT_AND_MAPPING_FROM_SAME_ITEMS_NODUP = _bidict_and_mapping_from_items() diff --git a/tests/hypothesis/test_properties.py b/tests/hypothesis/test_properties.py index 8d14bff..0df0b1e 100644 --- a/tests/hypothesis/test_properties.py +++ b/tests/hypothesis/test_properties.py @@ -15,7 +15,7 @@ from collections import OrderedDict from weakref import ref import pytest -from hypothesis import given +from hypothesis import HealthCheck, given, settings import _setup_hypothesis import _strategies as st @@ -43,6 +43,7 @@ def test_unequal_to_non_mapping(bi, not_a_mapping): @given(st.BIDICT_AND_MAPPING_FROM_DIFFERENT_ITEMS) +@settings(suppress_health_check=[HealthCheck.too_slow]) def test_unequal_to_mapping_with_different_items(bidict_and_mapping_from_different_items): """Bidicts should be unequal to mappings containing different items.""" bi, mapping = bidict_and_mapping_from_different_items