Skip to content

Commit df9df57

Browse files
author
Martin Journois
committed
TST: ADD test on Series index auto-completion
1 parent 7bbe001 commit df9df57

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

pandas/tests/series/test_api.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from pandas import Index, Series, DataFrame, date_range
1111
from pandas.core.indexes.datetimes import Timestamp
1212

13-
from pandas.compat import range
13+
from pandas.compat import range, lzip, isidentifier, string_types
1414
from pandas import compat
1515
import pandas.io.formats.printing as printing
1616
from pandas.util.testing import (assert_series_equal,
@@ -234,6 +234,29 @@ def test_tab_completion(self):
234234
assert 'str' not in dir(s)
235235
assert 'dt' in dir(s) # as it is a datetime categorical
236236

237+
@pytest.mark.parametrize("index", [
238+
tm.makeUnicodeIndex(10),
239+
tm.makeStringIndex(10),
240+
tm.makeCategoricalIndex(10),
241+
Index(['foo', 'bar', 'baz'] * 2),
242+
tm.makeDateIndex(10),
243+
tm.makePeriodIndex(10),
244+
tm.makeTimedeltaIndex(10),
245+
tm.makeIntIndex(10),
246+
tm.makeUIntIndex(10),
247+
tm.makeIntIndex(10),
248+
tm.makeFloatIndex(10),
249+
Index([True, False]),
250+
pd.MultiIndex.from_tuples(lzip('ABCD', 'EFGH')),
251+
pd.MultiIndex.from_tuples(lzip([0, 1, 2, 3], 'EFGH')), ])
252+
def test_index_tab_completion(self, index):
253+
# dir contains string-like values of the Index.
254+
s = pd.Series(index=index)
255+
dir_s = dir(s)
256+
for x in s.index.get_level_values(0):
257+
assert (not isinstance(x, string_types) or
258+
not isidentifier(x) or x in dir_s)
259+
237260
def test_not_hashable(self):
238261
s_empty = Series()
239262
s = Series([1])

0 commit comments

Comments
 (0)