Skip to content
Browse files

Let's see what happens if we use only NumPy machinery.

  • Loading branch information...
1 parent 113079c commit f930067ed954035db7db78147f9826256de5410b @stefanv committed Nov 29, 2011
Showing with 2 additions and 52 deletions.
  1. +2 −52 IPython/external/decorators/_decorators.py
View
54 IPython/external/decorators/_decorators.py
@@ -28,6 +28,8 @@
except:
pass
+from numpy.testing.decorators import knownfailureif
+
# End IPython changes
def slow(t):
@@ -174,58 +176,6 @@ def skipper_gen(*args, **kwargs):
return skip_decorator
-def knownfailureif(fail_condition, msg=None):
- """
- Make function raise KnownFailureTest exception if given condition is true.
-
- If the condition is a callable, it is used at runtime to dynamically
- make the decision. This is useful for tests that may require costly
- imports, to delay the cost until the test suite is actually executed.
-
- Parameters
- ----------
- fail_condition : bool or callable
- Flag to determine whether to mark the decorated test as a known
- failure (if True) or not (if False).
- msg : str, optional
- Message to give on raising a KnownFailureTest exception.
- Default is None.
-
- Returns
- -------
- decorator : function
- Decorator, which, when applied to a function, causes SkipTest
- to be raised when `skip_condition` is True, and the function
- to be called normally otherwise.
-
- Notes
- -----
- The decorator itself is decorated with the ``nose.tools.make_decorator``
- function in order to transmit function name, and various other metadata.
-
- """
- if msg is None:
- msg = 'Test skipped due to known failure'
-
- # Allow for both boolean or callable known failure conditions.
- if callable(fail_condition):
- fail_val = lambda : fail_condition()
- else:
- fail_val = lambda : fail_condition
-
- def knownfail_decorator(f):
- # Local import to avoid a hard nose dependency and only incur the
- # import time overhead at actual test-time.
- import nose
- def knownfailer(*args, **kwargs):
- if fail_val():
- raise KnownFailureTest, msg
- else:
- return f(*args, **kwargs)
- return nose.tools.make_decorator(f)(knownfailer)
-
- return knownfail_decorator
-
def deprecated(conditional=True):
"""
Filter deprecation warnings while running the test suite.

0 comments on commit f930067

Please sign in to comment.
Something went wrong with that request. Please try again.