Skip to content

Commit 8ec4218

Browse files
author
evgenii
committed
TST: skip speedup test when matplotlib is not installed
1 parent f756948 commit 8ec4218

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

pandas/tests/plotting/frame/test_linecollection_speedup.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@
33
instead of one Line2D per column (PR #61764).
44
"""
55

6-
from matplotlib.collections import LineCollection
7-
import matplotlib.pyplot as plt
86
import numpy as np
7+
import pytest
98

109
import pandas as pd
1110

11+
# Skip this entire module if matplotlib is not installed
12+
mpl = pytest.importorskip("matplotlib")
13+
plt = pytest.importorskip("matplotlib.pyplot")
14+
from matplotlib.collections import LineCollection
15+
1216

1317
def test_linecollection_used_for_wide_dataframe():
1418
rng = np.random.default_rng(0)
1519
df = pd.DataFrame(rng.standard_normal((10, 201)).cumsum(axis=0))
1620

1721
ax = df.plot(legend=False)
1822

19-
# one LineCollection, zero Line2D objects
23+
# exactly one LineCollection, and no Line2D artists
2024
assert sum(isinstance(c, LineCollection) for c in ax.collections) == 1
2125
assert len(ax.lines) == 0
2226

0 commit comments

Comments
 (0)