From b650c6715135d93a683715d06e47bb448d0b9390 Mon Sep 17 00:00:00 2001 From: Antony Lee Date: Fri, 20 Jul 2018 12:29:13 +0200 Subject: [PATCH] Don't assume cwd in test_ipynb. The Matplotlib test suite can be run from outside of the root git directory, e.g. with pytest --pyargs matplotlib.tests.test_backend_nbagg (mplcairo explicitly relies on that to reuse the Matplotlib test suite). To ensure this, find the example notebook relative to the path of the test module, rather than relative to the current working directory. --- lib/matplotlib/tests/test_backend_nbagg.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_backend_nbagg.py b/lib/matplotlib/tests/test_backend_nbagg.py index 513a11da64cb..f08460b892cc 100644 --- a/lib/matplotlib/tests/test_backend_nbagg.py +++ b/lib/matplotlib/tests/test_backend_nbagg.py @@ -1,7 +1,7 @@ - -import os +from pathlib import Path import subprocess import tempfile + import pytest nbformat = pytest.importorskip('nbformat') @@ -29,5 +29,6 @@ def _notebook_run(nb_file): def test_ipynb(): - nb, errors = _notebook_run('lib/matplotlib/tests/test_nbagg_01.ipynb') + nb, errors = _notebook_run( + str(Path(__file__).parent / 'test_nbagg_01.ipynb')) assert errors == []