Skip to content

Commit 8096bb8

Browse files
committed
Merge pull request ipython#1395 from takluyver/xunit-kf
Make Xunit count KnownFailure tests as skipped, not failures.
2 parents 920beab + 1997b59 commit 8096bb8

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

IPython/testing/iptest.py

+23-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
from IPython.testing import nosepatch
4343
# Now, proceed to import nose itself
4444
import nose.plugins.builtin
45+
from nose.plugins.xunit import Xunit
46+
from nose import SkipTest
4547
from nose.core import TestProgram
4648

4749
# Our own imports
@@ -52,7 +54,7 @@
5254

5355
from IPython.testing import globalipapp
5456
from IPython.testing.plugin.ipdoctest import IPythonDoctest
55-
from IPython.external.decorators import KnownFailure
57+
from IPython.external.decorators import KnownFailure, knownfailureif
5658

5759
pjoin = path.join
5860

@@ -79,6 +81,23 @@
7981
warnings.filterwarnings('ignore', 'wxPython/wxWidgets release number mismatch',
8082
UserWarning)
8183

84+
# ------------------------------------------------------------------------------
85+
# Monkeypatch Xunit to count known failures as skipped.
86+
# ------------------------------------------------------------------------------
87+
def monkeypatch_xunit():
88+
try:
89+
knownfailureif(True)(lambda: None)()
90+
except Exception as e:
91+
KnownFailureTest = type(e)
92+
93+
def addError(self, test, err, capt=None):
94+
if issubclass(err[0], KnownFailureTest):
95+
err = (SkipTest,) + err[1:]
96+
return self.orig_addError(test, err, capt)
97+
98+
Xunit.orig_addError = Xunit.addError
99+
Xunit.addError = addError
100+
82101
#-----------------------------------------------------------------------------
83102
# Logic for skipping doctests
84103
#-----------------------------------------------------------------------------
@@ -387,6 +406,9 @@ def run_iptest():
387406
`iptest all`. It simply calls nose with appropriate command line flags
388407
and accepts all of the standard nose arguments.
389408
"""
409+
# Apply our monkeypatch to Xunit
410+
if not hasattr(Xunit, 'orig_addError'):
411+
monkeypatch_xunit()
390412

391413
warnings.filterwarnings('ignore',
392414
'This will be removed soon. Use IPython.testing.util instead')

0 commit comments

Comments
 (0)