Skip to content

Commit 9444fef

Browse files
committed
TST: Fix plot composition test error messages
There are two issues: 1. We had not "opted" into the custom error messaging for the tests. 2. We have to be careful that we attach the result from compare_image to the original Compare instance (cmp._err) and not a copy of it. closes #955
1 parent 7c5005f commit 9444fef

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/conftest.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,11 @@ def build_test(self):
127127

128128

129129
def pytest_assertrepr_compare(op, left, right):
130-
if isinstance(left, ggplot) and isinstance(right, str) and op == "==":
130+
if (
131+
isinstance(left, (ggplot, Compose))
132+
and isinstance(right, str)
133+
and op == "=="
134+
):
131135
msg = (
132136
"images not close: {actual:s} vs. {expected:s} "
133137
"(RMS {rms:.2f})".format(**left._err)
@@ -252,10 +256,10 @@ def composition_equals(cmp: Compose, name: str) -> bool:
252256
test_file = inspect.stack()[1][1]
253257
filenames = make_test_image_filenames(name, test_file)
254258

255-
cmp = cmp + theme(dpi=DPI)
259+
_cmp = cmp + theme(dpi=DPI)
256260

257261
with _test_cleanup():
258-
cmp.save(filenames.result)
262+
_cmp.save(filenames.result)
259263

260264
if filenames.baseline.exists():
261265
shutil.copyfile(filenames.baseline, filenames.expected)

0 commit comments

Comments
 (0)