Skip to content

Commit f3fd1d9

Browse files
committed
add more dtypes to tests
1 parent 3956557 commit f3fd1d9

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

pandas/tests/series/test_constructors.py

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,21 +142,23 @@ def test_constructor_list_like(self):
142142
result = Series(obj, index=[0, 1, 2])
143143
assert_series_equal(result, expected)
144144

145-
@pytest.mark.parametrize('input_vals, dtype, expected', [
146-
([1, 2, 3], 'str', ['1', '2', '3']),
147-
([1, 2, 3], str, ['1', '2', '3']),
148-
([1, 2, 3], 'U', ['1', '2', '3']),
149-
([1.0, 2.0, 3.0], 'str', ['1.0', '2.0', '3.0']),
150-
([1.0, 2.0, 3.0], str, ['1.0', '2.0', '3.0']),
151-
([1.0, 2.0, 3.0], 'U', ['1.0', '2.0', '3.0'])
145+
@pytest.mark.parametrize('input_vals', [
146+
([1, 2]),
147+
([1.0, 2.0, np.nan]),
148+
(['1', '2']),
149+
(pd.date_range('1/1/2011', periods=2)),
150+
(pd.date_range('1/1/2011', periods=2, tz='US/Eastern')),
151+
(pd.Interval(left=0, right=5)),
152152
])
153-
def test_constructor_list_str(self, input_vals, dtype, expected):
153+
def test_constructor_list_str(self, input_vals):
154154
# GH 16605
155155
# Ensure that data elements are converted to strings when
156156
# dtype is str, 'str', or 'U'
157157

158-
result = Series(input_vals, dtype=dtype)
159-
assert_series_equal(result, Series(expected))
158+
for dtype in ['str', str, 'U']:
159+
result = Series(input_vals, dtype=dtype)
160+
expected = Series(input_vals).astype(dtype)
161+
assert_series_equal(result, expected)
160162

161163
def test_constructor_generator(self):
162164
gen = (i for i in range(10))

0 commit comments

Comments
 (0)