Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit fa30063

Browse files
committed
Make knownfailureif Pytest-compatible
1 parent d077cd1 commit fa30063

2 files changed

Lines changed: 17 additions & 4 deletions

File tree

IPython/external/decorators/_decorators.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,16 @@ def knownfail_decorator(f):
133133
# import time overhead at actual test-time.
134134
import nose
135135

136+
try:
137+
from pytest import xfail
138+
except ImportError:
139+
140+
def xfail():
141+
raise KnownFailureTest(msg)
142+
136143
def knownfailer(*args, **kwargs):
137144
if fail_condition:
138-
raise KnownFailureTest(msg)
145+
xfail(msg)
139146
else:
140147
return f(*args, **kwargs)
141148
return nose.tools.make_decorator(f)(knownfailer)

IPython/external/decorators/_numpy_testing_noseclasses.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@
77

88
from nose.plugins.errorclass import ErrorClass, ErrorClassPlugin
99

10-
class KnownFailureTest(Exception):
11-
'''Raise this exception to mark a test as a known failing test.'''
12-
pass
10+
11+
try:
12+
import pytest
13+
14+
KnownFailureTest = pytest.xfail.Exception
15+
except ImportError:
16+
17+
class KnownFailureTest(Exception):
18+
"""Raise this exception to mark a test as a known failing test."""
1319

1420

1521
class KnownFailure(ErrorClassPlugin):

0 commit comments

Comments
 (0)