Skip to content

Commit f70c7b0

Browse files
committed
TST, fix for issue pandas-dev#17978.
Incorporate review comments.
1 parent 8e67015 commit f70c7b0

File tree

1 file changed

+18
-26
lines changed

1 file changed

+18
-26
lines changed

pandas/tests/reshape/test_util.py

+18-26
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,27 @@
88
from datetime import date
99
from dateutil import relativedelta
1010

11-
from pandas.util._hypothesis import (st,
12-
given,
13-
settings,
14-
get_seq,
15-
assume)
16-
11+
from pandas.util import _hypothesis as hp
1712

1813
NO_OF_EXAMPLES_PER_TEST_CASE = 20
1914

2015

2116
class TestCartesianProduct(object):
2217

23-
@settings(max_examples=NO_OF_EXAMPLES_PER_TEST_CASE)
24-
@given(get_seq((str,), False, 1, 1),
25-
get_seq((int,), False, 1, 2))
18+
@hp.settings(max_examples=20)
19+
@hp.given(hp.st.lists(hp.st.text(string.ascii_letters, min_size=1, max_size=1),
20+
min_size=1, max_size=3),
21+
hp.get_seq((int,), False, 1, 2))
2622
def test_simple(self, x, y):
27-
x = list(x[0])
28-
# non-empty test case is handled in test_empty,
29-
# therefore ignore it here.
30-
assume(len(x) != 0)
3123
result1, result2 = cartesian_product([x, y])
3224
expected1 = np.array([item1 for item1 in x for item2 in y])
3325
expected2 = np.array([item2 for item1 in x for item2 in y])
3426

3527
tm.assert_numpy_array_equal(result1, expected1)
3628
tm.assert_numpy_array_equal(result2, expected2)
3729

38-
@settings(max_examples=NO_OF_EXAMPLES_PER_TEST_CASE)
39-
@given(st.dates(min_value=date(1900, 1, 1), max_value=date(2100, 1, 1)))
30+
@hp.settings(max_examples=20)
31+
@hp.given(hp.st.dates(min_value=date(1900, 1, 1), max_value=date(2100, 1, 1)))
4032
def test_datetimeindex(self, d):
4133
# regression test for GitHub issue #6439
4234
# make sure that the ordering on datetimeindex is consistent
@@ -49,10 +41,10 @@ def test_datetimeindex(self, d):
4941
tm.assert_index_equal(result1, expected1)
5042
tm.assert_index_equal(result2, expected2)
5143

52-
@settings(max_examples=NO_OF_EXAMPLES_PER_TEST_CASE)
53-
@given(st.lists(st.nothing()),
54-
get_seq((int,), False, min_size=1, max_size=10),
55-
get_seq((str,), False, min_size=1, max_size=10))
44+
@hp.settings(max_examples=20)
45+
@hp.given(hp.st.lists(hp.st.nothing()),
46+
hp.get_seq((int,), False, min_size=1, max_size=10),
47+
hp.get_seq((str,), False, min_size=1, max_size=10))
5648
def test_empty(self, empty_list, list_of_int, list_of_str):
5749
# product of empty factors
5850
X = [empty_list, list_of_int, empty_list]
@@ -70,13 +62,13 @@ def test_empty(self, empty_list, list_of_int, list_of_str):
7062
expected = []
7163
assert result == expected
7264

73-
@settings(max_examples=NO_OF_EXAMPLES_PER_TEST_CASE)
74-
@given(st.integers(),
75-
st.text(string.ascii_letters, min_size=1),
76-
get_seq((int, str), True, min_size=1),
77-
st.builds(lambda *x: list(x), st.integers(),
78-
st.text(string.ascii_letters, min_size=1),
79-
st.lists(st.integers(), min_size=1)))
65+
@hp.settings(max_examples=20)
66+
@hp.given(hp.st.integers(),
67+
hp.st.text(string.ascii_letters, min_size=1),
68+
hp.get_seq((int, str), True, min_size=1),
69+
hp.st.builds(lambda *x: list(x), hp.st.integers(),
70+
hp.st.text(string.ascii_letters, min_size=1),
71+
hp.st.lists(hp.st.integers(), min_size=1)))
8072
def test_invalid_input(self, number, text, seq, mixed_seq):
8173

8274
invalid_inputs = [number,

0 commit comments

Comments
 (0)