Skip to content

Commit dcbae6a

Browse files
committed
Handle pytest's new ParameterSet for markers.
Using pytest.param(..., marks=pytest.mark.something) is a different type than if using pytest.mark.something(...), so we need to handle that case on skipping extensions.
1 parent 28bf5e6 commit dcbae6a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

lib/matplotlib/testing/decorators.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,18 @@ def _xfail_if_format_is_uncomparable(extension):
158158

159159
def _mark_xfail_if_format_is_uncomparable(extension):
160160
if isinstance(extension, str):
161-
will_fail = extension not in comparable_formats()
161+
name = extension
162+
elif isinstance(extension, tuple):
163+
# Extension might be a pytest ParameterSet instead of a plain string.
164+
# Unfortunately, this type is not exposed, so since it's a namedtuple,
165+
# check for a tuple instead.
166+
name = extension.values[0]
162167
else:
163168
# Extension might be a pytest marker instead of a plain string.
164-
will_fail = extension.args[0] not in comparable_formats()
165-
if will_fail:
166-
fail_msg = 'Cannot compare %s files on this system' % extension
169+
name = extension.args[0]
170+
171+
if name not in comparable_formats():
172+
fail_msg = 'Cannot compare %s files on this system' % (name, )
167173
import pytest
168174
return pytest.mark.xfail(extension, reason=fail_msg, strict=False,
169175
raises=ImageComparisonFailure)

0 commit comments

Comments
 (0)