Skip to content

Commit

Permalink
Test generating compound dtypes & data with bytes & unicode strings in
Browse files Browse the repository at this point in the history
  • Loading branch information
takluyver committed Sep 6, 2019
1 parent 801f9a1 commit d11f2e8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion hypothesis-python/tests/numpy/test_gen_data.py
Expand Up @@ -194,11 +194,29 @@ def test_can_generate_scalar_dtypes(dtype):
assert isinstance(dtype, np.dtype)


@given(nps.nested_dtypes())
@given(
nps.nested_dtypes(
subtype_strategy=st.one_of(
nps.scalar_dtypes(), nps.byte_string_dtypes(), nps.unicode_string_dtypes()
)
)
)
def test_can_generate_compound_dtypes(dtype):
assert isinstance(dtype, np.dtype)


@given(
nps.nested_dtypes(
subtype_strategy=st.one_of(
nps.scalar_dtypes(), nps.byte_string_dtypes(), nps.unicode_string_dtypes()
)
).flatmap(lambda dt: nps.arrays(dtype=dt, shape=1))
)
def test_can_generate_data_compound_dtypes(arr):
# This is meant to catch the class of errors which prompted PR #2085
assert isinstance(arr, np.ndarray)


@given(nps.nested_dtypes(max_itemsize=400), st.data())
def test_infer_strategy_from_dtype(dtype, data):
# Given a dtype
Expand Down

0 comments on commit d11f2e8

Please sign in to comment.