From 30b34108dbfba8b1e15eb39723809da1a800e847 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Mon, 29 Sep 2014 20:58:31 -0400 Subject: [PATCH 1/3] BUG/TST : skip example pep8 if don't know source path closes #3596 --- lib/matplotlib/tests/test_coding_standards.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index 8864b99c2969..0d3956e2d74e 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -6,6 +6,7 @@ from nose.tools import assert_equal from nose.plugins.skip import SkipTest +from matplotlib.testing.noseclasses import KnownFailureTest try: import pep8 @@ -256,8 +257,10 @@ def test_pep8_conformance_installed_files(): def test_pep8_conformance_examples(): - mpldirdefault = os.path.join(os.getcwd(), '..', '..', '..') - mpldir = os.environ.get('MPL_REPO_DIR', mpldirdefault) + mpldir = os.environ.get('MPL_REPO_DIR', None) + if mpldir is None: + raise KnownFailureTest("can not find the examples") + exdir = os.path.join(mpldir, 'examples') blacklist = ['color', 'event_handling', From ae7345b154fea3b5b9f87c94d5d6807d00fd5433 Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 30 Sep 2014 08:50:43 -0400 Subject: [PATCH 2/3] TST : made known-failure message more useful --- lib/matplotlib/tests/test_coding_standards.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index 0d3956e2d74e..501308711a58 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -259,7 +259,9 @@ def test_pep8_conformance_installed_files(): def test_pep8_conformance_examples(): mpldir = os.environ.get('MPL_REPO_DIR', None) if mpldir is None: - raise KnownFailureTest("can not find the examples") + raise KnownFailureTest("can not find the examples, set env " + "MPL_REPO_DIR to point to the top-level path " + "of the source tree") exdir = os.path.join(mpldir, 'examples') blacklist = ['color', From 9366eb4e8dd44a30aa952f6cd7a52addcdc523be Mon Sep 17 00:00:00 2001 From: Thomas A Caswell Date: Tue, 30 Sep 2014 09:21:57 -0400 Subject: [PATCH 3/3] TST : made search for examples smarter Will find examples if cwd is anywhere is the source tree. --- lib/matplotlib/tests/test_coding_standards.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/lib/matplotlib/tests/test_coding_standards.py b/lib/matplotlib/tests/test_coding_standards.py index 501308711a58..5a0c35331a25 100644 --- a/lib/matplotlib/tests/test_coding_standards.py +++ b/lib/matplotlib/tests/test_coding_standards.py @@ -258,6 +258,15 @@ def test_pep8_conformance_installed_files(): def test_pep8_conformance_examples(): mpldir = os.environ.get('MPL_REPO_DIR', None) + if mpldir is None: + # try and guess! + fp = os.getcwd() + while len(fp) > 2: + if os.path.isdir(os.path.join(fp, 'examples')): + mpldir = fp + break + fp, tail = os.path.split(fp) + if mpldir is None: raise KnownFailureTest("can not find the examples, set env " "MPL_REPO_DIR to point to the top-level path "