From a3875ddc502b5ae920c1f982f2899c4b4e8315bd Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 19 Nov 2015 15:09:21 +0000 Subject: [PATCH 1/2] Raise a meaningful error message to make the use of the @image_comparison decorator more user-friendly for projects other than matplotlib. --- lib/matplotlib/testing/decorators.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index 000c93d64d90..f78ff39c3733 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -360,7 +360,12 @@ def _image_directories(func): # namespace package pip installed and run via the nose # multiprocess plugin or as a specific test this may be # missing. See https://github.com/matplotlib/matplotlib/issues/3314 - assert mods.pop(0) == 'tests' + if mods[0] != 'tests': + raise ValueError( + "Test does not live in a submodule named 'tests'. Please make " + "sure that there is a parent directory named 'tests' and that " + "it contains a __init__.py file (can be empty).") + mods.pop(0) # ignore the leading 'tests' part of the module name subdir = os.path.join(*mods) import imp From 8683f54c2b80f67c0be8b59ed2b06ac2afb854fb Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Thu, 19 Nov 2015 17:47:00 +0000 Subject: [PATCH 2/2] Change exception type back to AssertionError (in a somewhat shot-in-the-dark attempt to fix the Travis build with numpy 1.6). --- lib/matplotlib/testing/decorators.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/testing/decorators.py b/lib/matplotlib/testing/decorators.py index f78ff39c3733..aece81d91715 100644 --- a/lib/matplotlib/testing/decorators.py +++ b/lib/matplotlib/testing/decorators.py @@ -361,7 +361,7 @@ def _image_directories(func): # multiprocess plugin or as a specific test this may be # missing. See https://github.com/matplotlib/matplotlib/issues/3314 if mods[0] != 'tests': - raise ValueError( + raise AssertionError( "Test does not live in a submodule named 'tests'. Please make " "sure that there is a parent directory named 'tests' and that " "it contains a __init__.py file (can be empty).")