Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 833f48d

Browse files
committed
Fail-fast when trying to run tests with too-old pytest.
Otherwise the error message can be quite obscure.
1 parent d72f069 commit 833f48d

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

lib/matplotlib/tests/__init__.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import os
1+
from distutils.version import LooseVersion
2+
from pathlib import Path
23

4+
import pytest
35

4-
# Check that the test directories exist
5-
if not os.path.exists(os.path.join(
6-
os.path.dirname(__file__), 'baseline_images')):
6+
7+
# Check that the test directories exist.
8+
if not (Path(__file__).parent / 'baseline_images').exists():
79
raise IOError(
810
'The baseline image directory does not exist. '
911
'This is most likely because the test data is not installed. '
1012
'You may need to install matplotlib from source to get the '
1113
'test data.')
14+
if LooseVersion(pytest.__version__) < "3.6":
15+
raise RuntimeError('pytest>=3.6 is required to run the tests')

0 commit comments

Comments
 (0)