Skip to content

Commit 3ac4895

Browse files
committed
TST: Additional Styler init and repr tests
1 parent 9093df8 commit 3ac4895

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

pandas/formats/style.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def __init__(self, data, precision=None, table_styles=None, uuid=None,
133133
self._todo = []
134134

135135
if not isinstance(data, (pd.Series, pd.DataFrame)):
136-
raise TypeError
136+
raise TypeError("``data`` must be a Series or DataFrame")
137137
if data.ndim == 1:
138138
data = data.to_frame()
139139
if not data.index.is_unique or not data.columns.is_unique:

pandas/tests/formats/test_style.py

+11
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ def h(x, foo='bar'):
4646
'c': pd.Categorical(['a', 'b'])})
4747
]
4848

49+
def test_init_non_pandas(self):
50+
with tm.assertRaises(TypeError):
51+
Styler([1, 2, 3])
52+
53+
def test_init_series(self):
54+
result = Styler(pd.Series([1, 2]))
55+
self.assertEqual(result.data.ndim, 2)
56+
57+
def test_repr_html_ok(self):
58+
self.styler._repr_html_()
59+
4960
def test_update_ctx(self):
5061
self.styler._update_ctx(self.attrs)
5162
expected = {(0, 0): ['color: red'],

0 commit comments

Comments
 (0)