Skip to content

Commit 3b296d6

Browse files
committed
improve tests, integrate into styler.clear()
1 parent 3dd5cb2 commit 3b296d6

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

pandas/io/formats/style.py

+2
Original file line numberDiff line numberDiff line change
@@ -615,6 +615,8 @@ def clear(self) -> None:
615615
Returns None.
616616
"""
617617
self.ctx.clear()
618+
self.tooltip_styles = []
619+
self.set_tooltip_class(name="pd-t", properties=None)
618620
self._todo = []
619621

620622
def _compute(self):

pandas/tests/io/formats/test_style.py

+14-6
Original file line numberDiff line numberDiff line change
@@ -1697,20 +1697,28 @@ def test_tooltip_render(self):
16971697
ttips = pd.DataFrame(
16981698
data=[["Min", ""], [np.nan, "Max"]], columns=df.columns, index=df.index
16991699
)
1700-
s = Styler(df, uuid="_").set_tooltips(ttips)
1700+
s = Styler(df, uuid="_").set_tooltips(ttips).render()
17011701
# test tooltip table level class
1702-
assert "#T__ .pd-t {" in s.render()
1703-
# test 'min' tooltip added
1702+
assert "#T__ .pd-t {\n visibility: hidden;\n" in s
1703+
# test 'Min' tooltip added
17041704
assert (
17051705
"#T__ #T__row0_col0:hover .pd-t {\n visibility: visible;\n } "
17061706
+ ' #T__ #T__row0_col0 .pd-t::after {\n content: "Min";\n }'
1707-
in s.render()
1707+
in s
17081708
)
1709-
# test 'max' tooltip added
1709+
assert (
1710+
'<td id="T__row0_col0" class="data row0 col0" >0<span class="pd-t"></span></td>'
1711+
in s
1712+
)
1713+
# test 'Max' tooltip added
17101714
assert (
17111715
"#T__ #T__row1_col1:hover .pd-t {\n visibility: visible;\n } "
17121716
+ ' #T__ #T__row1_col1 .pd-t::after {\n content: "Max";\n }'
1713-
in s.render()
1717+
in s
1718+
)
1719+
assert (
1720+
'<td id="T__row1_col1" class="data row1 col1" >3<span class="pd-t"></span></td>'
1721+
in s
17141722
)
17151723

17161724
def test_tooltip_ignored(self):

0 commit comments

Comments
 (0)