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