@@ -234,38 +234,28 @@ 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- def test_index_tab_completion (self ):
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 ):
238253 # dir contains string-like values of the Index.
239- for index in [tm .makeUnicodeIndex (10 ),
240- tm .makeStringIndex (100 ),
241- tm .makeCategoricalIndex (100 ),
242- Index (['foo' , 'foo' ,
243- 'bar' , 'bar' ,
244- 'baz' , 'baz' ]),
245- tm .makeDateIndex (100 ),
246- tm .makePeriodIndex (100 ),
247- tm .makeTimedeltaIndex (100 ),
248- tm .makeIntIndex (100 ),
249- tm .makeUIntIndex (100 ),
250- tm .makeIntIndex (100 ),
251- tm .makeFloatIndex (100 ),
252- Index ([True , False ]),
253- ]:
254- s = pd .Series (index = index )
255- dir_s = dir (s )
256- for x in s .index :
257- assert (not isinstance (x , string_types ) or
258- not isidentifier (x ) or x in dir_s )
259-
260- # dir contains string-like values of the MultiIndex first level.
261- for index in [pd .MultiIndex .from_tuples (lzip ('ABCD' , 'EFGH' )),
262- pd .MultiIndex .from_tuples (lzip ([0 , 1 , 2 , 3 ], 'EFGH' )),
263- ]:
264- s = pd .Series (index = index )
265- dir_s = dir (s )
266- for x in s .index :
267- assert (not isinstance (x [0 ], string_types ) or
268- not isidentifier (x [0 ]) or x [0 ] in dir_s )
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 )
269259
270260 def test_not_hashable (self ):
271261 s_empty = Series ()
0 commit comments