Skip to content

Commit 850fbb5

Browse files
WillAydjreback
authored andcommitted
Skipped flaky part of test_time (#25894)
1 parent ac318d2 commit 850fbb5

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pandas/tests/plotting/test_datetimelike.py

+27
Original file line numberDiff line numberDiff line change
@@ -1104,6 +1104,33 @@ def test_time(self):
11041104
xp = time(h, m, s).strftime('%H:%M')
11051105
assert xp == rs
11061106

1107+
@pytest.mark.slow
1108+
@pytest.mark.xfail(strict=False, reason="Unreliable test")
1109+
def test_time_change_xlim(self):
1110+
t = datetime(1, 1, 1, 3, 30, 0)
1111+
deltas = np.random.randint(1, 20, 3).cumsum()
1112+
ts = np.array([(t + timedelta(minutes=int(x))).time() for x in deltas])
1113+
df = DataFrame({'a': np.random.randn(len(ts)),
1114+
'b': np.random.randn(len(ts))},
1115+
index=ts)
1116+
fig, ax = self.plt.subplots()
1117+
df.plot(ax=ax)
1118+
1119+
# verify tick labels
1120+
fig.canvas.draw()
1121+
ticks = ax.get_xticks()
1122+
labels = ax.get_xticklabels()
1123+
for t, l in zip(ticks, labels):
1124+
m, s = divmod(int(t), 60)
1125+
h, m = divmod(m, 60)
1126+
rs = l.get_text()
1127+
if len(rs) > 0:
1128+
if s != 0:
1129+
xp = time(h, m, s).strftime('%H:%M:%S')
1130+
else:
1131+
xp = time(h, m, s).strftime('%H:%M')
1132+
assert xp == rs
1133+
11071134
# change xlim
11081135
ax.set_xlim('1:30', '5:00')
11091136

0 commit comments

Comments
 (0)