|
26 | 26 | from .exceptions import ImageComparisonFailure
|
27 | 27 |
|
28 | 28 |
|
29 |
| -def _knownfailureif(fail_condition, msg=None, known_exception_class=None): |
30 |
| - """ |
31 |
| -
|
32 |
| - Assume a will fail if *fail_condition* is True. *fail_condition* |
33 |
| - may also be False or the string 'indeterminate'. |
34 |
| -
|
35 |
| - *msg* is the error message displayed for the test. |
36 |
| -
|
37 |
| - If *known_exception_class* is not None, the failure is only known |
38 |
| - if the exception is an instance of this class. (Default = None) |
39 |
| -
|
40 |
| - """ |
41 |
| - import pytest |
42 |
| - if fail_condition == 'indeterminate': |
43 |
| - fail_condition, strict = True, False |
44 |
| - else: |
45 |
| - fail_condition, strict = bool(fail_condition), True |
46 |
| - return pytest.mark.xfail(condition=fail_condition, reason=msg, |
47 |
| - raises=known_exception_class, strict=strict) |
48 |
| - |
49 |
| - |
50 | 29 | def _do_cleanup(original_units_registry, original_settings):
|
51 | 30 | plt.close('all')
|
52 | 31 |
|
@@ -151,14 +130,13 @@ def check_freetype_version(ver):
|
151 | 130 |
|
152 | 131 |
|
153 | 132 | def _checked_on_freetype_version(required_freetype_version):
|
154 |
| - if check_freetype_version(required_freetype_version): |
155 |
| - return lambda f: f |
156 |
| - |
| 133 | + import pytest |
157 | 134 | reason = ("Mismatched version of freetype. "
|
158 | 135 | "Test requires '%s', you have '%s'" %
|
159 | 136 | (required_freetype_version, ft2font.__freetype_version__))
|
160 |
| - return _knownfailureif('indeterminate', msg=reason, |
161 |
| - known_exception_class=ImageComparisonFailure) |
| 137 | + return pytest.mark.xfail( |
| 138 | + not check_freetype_version(required_freetype_version), |
| 139 | + reason=reason, raises=ImageComparisonFailure, strict=False) |
162 | 140 |
|
163 | 141 |
|
164 | 142 | def remove_ticks_and_titles(figure):
|
@@ -194,14 +172,11 @@ def _raise_on_image_difference(expected, actual, tol):
|
194 | 172 |
|
195 | 173 |
|
196 | 174 | def _xfail_if_format_is_uncomparable(extension):
|
197 |
| - will_fail = extension not in comparable_formats() |
198 |
| - if will_fail: |
199 |
| - fail_msg = 'Cannot compare %s files on this system' % extension |
200 |
| - else: |
201 |
| - fail_msg = 'No failure expected' |
202 |
| - |
203 |
| - return _knownfailureif(will_fail, fail_msg, |
204 |
| - known_exception_class=ImageComparisonFailure) |
| 175 | + import pytest |
| 176 | + return pytest.mark.xfail( |
| 177 | + extension not in comparable_formats(), |
| 178 | + reason='Cannot compare {} files on this system'.format(extension), |
| 179 | + raises=ImageComparisonFailure, strict=True) |
205 | 180 |
|
206 | 181 |
|
207 | 182 | def _mark_xfail_if_format_is_uncomparable(extension):
|
|
0 commit comments