From 876beccb8fa2bb91133aa5214d16b98fd279047f Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Mon, 10 Dec 2018 23:58:07 +0100 Subject: [PATCH] Fail-fast when trying to run tests with too-old pytest. Otherwise the error message can be quite obscure. --- lib/matplotlib/tests/__init__.py | 7 +++---- pytest.ini | 2 ++ 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/__init__.py b/lib/matplotlib/tests/__init__.py index 51167288ca81..7c4c5e946b6b 100644 --- a/lib/matplotlib/tests/__init__.py +++ b/lib/matplotlib/tests/__init__.py @@ -1,9 +1,8 @@ -import os +from pathlib import Path -# Check that the test directories exist -if not os.path.exists(os.path.join( - os.path.dirname(__file__), 'baseline_images')): +# Check that the test directories exist. +if not (Path(__file__).parent / 'baseline_images').exists(): raise IOError( 'The baseline image directory does not exist. ' 'This is most likely because the test data is not installed. ' diff --git a/pytest.ini b/pytest.ini index fdad48c2e92f..bc59294e8bca 100644 --- a/pytest.ini +++ b/pytest.ini @@ -1,4 +1,6 @@ [pytest] +minversion = 3.6 + testpaths = lib python_files = test_*.py