Skip to content

Commit aa6b4a9

Browse files
committed
tweak tests as requested on pr
parametrize tests and use iloc to check value
1 parent e9a290d commit aa6b4a9

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

pandas/tests/series/test_constructors.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -137,22 +137,19 @@ def test_constructor_no_data_index_order(self):
137137
def test_constructor_no_data_string_type(self):
138138
# GH 22477
139139
result = pd.Series(index=[1], dtype=str)
140-
assert result.isna().all()
140+
assert np.isnan(result.iloc[0])
141141

142-
def test_constructor_single_element_string_type(self):
142+
@pytest.mark.parametrize('item', ['13'])
143+
def test_constructor_single_element_string_type(self, item):
143144
# GH 22477
144-
result = pd.Series(13, index=[1], dtype=str)
145-
assert result.values.tolist() == ['13']
145+
result = pd.Series(int(item), index=[1], dtype=str)
146+
assert result.iloc[0] == item
146147

147-
def test_constructor_string_element_string_type(self):
148+
@pytest.mark.parametrize('item', ['entry', 'ѐ'])
149+
def test_constructor_string_element_string_type(self, item):
148150
# GH 22477
149-
result = pd.Series('entry', index=[1], dtype=str)
150-
assert result.values.tolist() == ['entry']
151-
152-
def test_constructor_unicode_element_string_type(self):
153-
# GH 22477
154-
result = pd.Series('ѐ', index=[1], dtype=str)
155-
assert result.values.tolist() == ['ѐ']
151+
result = pd.Series(item, index=[1], dtype=str)
152+
assert result.iloc[0] == item
156153

157154
def test_constructor_dtype_str_na_values(self, string_dtype):
158155
# https://github.com/pandas-dev/pandas/issues/21083

0 commit comments

Comments
 (0)