Use one_of rather than sampled_from in hypothesis tests.

This commit is contained in:
Joshua Bronson 2022-02-02 21:55:04 +00:00
parent b5d2d393c3
commit f1493e0778
1 changed files with 15 additions and 10 deletions

View File

@ -18,17 +18,22 @@ from . import _types as t
MAX = int(getenv('HYPOTHESIS_GEN_MAX_SIZE', '0')) or None
def one_of(items):
return st.one_of((st.just(i) for i in items))
DATA = st.data()
BIDICT_TYPES = st.sampled_from(t.BIDICT_TYPES)
MUTABLE_BIDICT_TYPES = st.sampled_from(t.MUTABLE_BIDICT_TYPES)
FROZEN_BIDICT_TYPES = st.sampled_from(t.FROZEN_BIDICT_TYPES)
ORDERED_BIDICT_TYPES = st.sampled_from(t.ORDERED_BIDICT_TYPES)
REVERSIBLE_BIDICT_TYPES = st.sampled_from(t.REVERSIBLE_BIDICT_TYPES)
MAPPING_TYPES = st.sampled_from(t.MAPPING_TYPES)
NON_BI_MAPPING_TYPES = st.sampled_from(t.NON_BI_MAPPING_TYPES)
ORDERED_MAPPING_TYPES = st.sampled_from(t.ORDERED_MAPPING_TYPES)
HASHABLE_MAPPING_TYPES = st.sampled_from(t.HASHABLE_MAPPING_TYPES)
ON_DUP_ACTIONS = st.sampled_from((DROP_NEW, DROP_OLD, RAISE))
BIDICT_TYPES = one_of(t.BIDICT_TYPES)
MUTABLE_BIDICT_TYPES = one_of(t.MUTABLE_BIDICT_TYPES)
FROZEN_BIDICT_TYPES = one_of(t.FROZEN_BIDICT_TYPES)
ORDERED_BIDICT_TYPES = one_of(t.ORDERED_BIDICT_TYPES)
REVERSIBLE_BIDICT_TYPES = one_of(t.REVERSIBLE_BIDICT_TYPES)
MAPPING_TYPES = one_of(t.MAPPING_TYPES)
NON_BI_MAPPING_TYPES = one_of(t.NON_BI_MAPPING_TYPES)
ORDERED_MAPPING_TYPES = one_of(t.ORDERED_MAPPING_TYPES)
HASHABLE_MAPPING_TYPES = one_of(t.HASHABLE_MAPPING_TYPES)
ON_DUP_ACTIONS = one_of((DROP_NEW, DROP_OLD, RAISE))
ON_DUP = st.tuples(ON_DUP_ACTIONS, ON_DUP_ACTIONS, ON_DUP_ACTIONS).map(OnDup._make)
TEXT = st.text()