Skip to content

Commit

Permalink
TST: Add test on DataFrame columns auto-completion
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Journois committed Nov 29, 2017
1 parent 9cc7215 commit 43e716c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pandas/tests/frame/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,20 @@ def test_column_contains_typeerror(self):
except TypeError:
pass

def test_tab_completion(self):
# DataFrame whose columns are identifiers shall have them in __dir__.
df = pd.DataFrame([list('abcd'), list('efgh')], columns=list('ABCD'))
assert 'A' in dir(df)
assert isinstance(df.__getitem__('A'), pd.Series)

# DataFrame whose first-level columns are identifiers shall have
# them in __dir__.
df = pd.DataFrame(
[list('abcd'), list('efgh')],
columns=pd.MultiIndex.from_tuples(list(zip('ABCD', 'EFGH'))))
assert 'A' in dir(df)
assert isinstance(df.__getitem__('A'), pd.DataFrame)

def test_not_hashable(self):
df = self.klass([1])
pytest.raises(TypeError, hash, df)
Expand Down

0 comments on commit 43e716c

Please sign in to comment.