From ed475d5727411ff4b6b22b3413c42b69bf6f56dd Mon Sep 17 00:00:00 2001 From: jab Date: Fri, 22 Mar 2019 17:46:15 +0000 Subject: [PATCH] fix example generation for hypothesis test namedbidict_raises_on_invalid_name --- tests/hypothesis/_strategies.py | 7 +++++-- tests/hypothesis/test_properties.py | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/hypothesis/_strategies.py b/tests/hypothesis/_strategies.py index 5a13511..41e0c11 100644 --- a/tests/hypothesis/_strategies.py +++ b/tests/hypothesis/_strategies.py @@ -12,14 +12,13 @@ from collections import OrderedDict from hypothesis import assume, strategies as st from bidict import IGNORE, OVERWRITE, RAISE, OrderedBidictBase, namedbidict -from bidict.compat import izip +from bidict.compat import PY2, izip import _types as t # pylint: disable=invalid-name - DATA = st.data() RAND = st.randoms() BIDICT_TYPES = st.sampled_from(t.BIDICT_TYPES) @@ -49,6 +48,10 @@ LISTS_PAIRS = st.lists(st.tuples(IMMUTABLES, IMMUTABLES), max_size=LISTS_MAX_SIZ NON_MAPPINGS = IMMUTABLES | LISTS_PAIRS +IDENTIFIER_TYPE = TEXT +if PY2: + IDENTIFIER_TYPE = IDENTIFIER_TYPE.map(lambda x: x.encode('utf-8')) + @st.composite def _lists_pairs_with_duplication(draw): diff --git a/tests/hypothesis/test_properties.py b/tests/hypothesis/test_properties.py index 0df0b1e..672e692 100644 --- a/tests/hypothesis/test_properties.py +++ b/tests/hypothesis/test_properties.py @@ -231,7 +231,7 @@ def test_orderedbidict_iterkeys_itervals_iteritems(ob): assert list(ob.iteritems()) == ob.items() -@given(st.st.tuples(st.TEXT, st.TEXT, st.TEXT)) +@given(st.st.tuples(st.IDENTIFIER_TYPE, st.IDENTIFIER_TYPE, st.IDENTIFIER_TYPE)) def test_namedbidict_raises_on_invalid_name(names): """:func:`bidict.namedbidict` should raise if given invalid names.""" typename, keyname, valname = names