Skip to content

Commit 1ba93fc

Browse files
committed
ENH: Replace raising Exception with pytest.fail().
Not only does this seem more fitting, but it permits suppressing the traceback; currently this traceback was only into the pytest-mpl plugin code, so it wasn't very useful at all for users.
1 parent c2fd488 commit 1ba93fc

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

pytest_mpl/plugin.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,11 +179,9 @@ def item_function_wrapper(*args, **kwargs):
179179
baseline_image_ref = os.path.abspath(os.path.join(os.path.dirname(item.fspath.strpath), baseline_dir, filename))
180180

181181
if not os.path.exists(baseline_image_ref):
182-
raise Exception("""Image file not found for comparison test
183-
Generated Image:
184-
\t{test}
185-
This is expected for new tests.""".format(
186-
test=test_image))
182+
pytest.fail("Image file not found for comparison test. "
183+
"(This is expected for new tests.)\nGenerated Image: "
184+
"\n\t{test}".format(test=test_image), pytrace=False)
187185

188186
# distutils may put the baseline images in non-accessible places,
189187
# copy to our tmpdir to be sure to keep them in case of failure
@@ -195,7 +193,7 @@ def item_function_wrapper(*args, **kwargs):
195193
if msg is None:
196194
shutil.rmtree(result_dir)
197195
else:
198-
raise Exception(msg)
196+
pytest.fail(msg, pytrace=False)
199197

200198
else:
201199

0 commit comments

Comments
 (0)