30
30
make_test_filename
31
31
32
32
33
+ def knownfail (msg ):
34
+ # TODO: This is temporary solution until migration to `pytest`
35
+ if getattr (matplotlib , '_called_from_pytest' , False ):
36
+ import pytest
37
+ pytest .xfail (msg )
38
+ else :
39
+ raise KnownFailureTest (msg )
40
+
41
+
33
42
def knownfailureif (fail_condition , msg = None , known_exception_class = None ):
34
43
"""
35
44
@@ -42,6 +51,13 @@ def knownfailureif(fail_condition, msg=None, known_exception_class=None ):
42
51
if the exception is an instance of this class. (Default = None)
43
52
44
53
"""
54
+ # TODO: This is temporary solution until migration to `pytest`
55
+ if getattr (matplotlib , '_called_from_pytest' , False ):
56
+ import pytest
57
+ strict = fail_condition and fail_condition != 'indeterminate'
58
+ return pytest .mark .xfail (condition = fail_condition , reason = msg ,
59
+ raises = known_exception_class , strict = strict )
60
+
45
61
# based on numpy.testing.dec.knownfailureif
46
62
if msg is None :
47
63
msg = 'Test known to fail'
@@ -264,7 +280,7 @@ def do_test(fignum, actual_fname, expected_fname):
264
280
'(RMS %(rms).3f)' % err )
265
281
except ImageComparisonFailure :
266
282
if not check_freetype_version (self ._freetype_version ):
267
- raise KnownFailureTest (
283
+ knownfail (
268
284
"Mismatched version of freetype. Test requires '%s', you have '%s'" %
269
285
(self ._freetype_version , ft2font .__freetype_version__ ))
270
286
raise
0 commit comments