Skip to content

Commit b9e3577

Browse files
authored
Merge pull request #47 from jnothman/lazy
import matplotlib lazily
2 parents 7766591 + 7ccafa4 commit b9e3577

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

pytest_mpl/plugin.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,12 @@
3939

4040
import pytest
4141

42-
import matplotlib
43-
import matplotlib.pyplot as plt
44-
from matplotlib.testing.compare import compare_images
45-
from matplotlib.testing.decorators import ImageComparisonTest as MplImageComparisonTest
46-
4742
if sys.version_info[0] == 2:
4843
from urllib import urlopen
4944
else:
5045
from urllib.request import urlopen
5146

5247

53-
MPL_LT_15 = LooseVersion(matplotlib.__version__) < LooseVersion('1.5')
54-
55-
5648
def _download_file(url):
5749
u = urlopen(url)
5850
result_dir = tempfile.mkdtemp()
@@ -115,6 +107,13 @@ def __init__(self, config, baseline_dir=None, generate_dir=None, results_dir=Non
115107

116108
def pytest_runtest_setup(self, item):
117109

110+
import matplotlib
111+
import matplotlib.pyplot as plt
112+
from matplotlib.testing.compare import compare_images
113+
from matplotlib.testing.decorators import ImageComparisonTest as MplImageComparisonTest
114+
115+
MPL_LT_15 = LooseVersion(matplotlib.__version__) < LooseVersion('1.5')
116+
118117
compare = item.keywords.get('mpl_image_compare')
119118

120119
if compare is None:

0 commit comments

Comments
 (0)