#NEWLINE# def knownfailureif( fail_condition , msg = None ) : #NEWLINE# #INDENT# '\n    Make function raise KnownFailureTest exception if given condition is true.\n\n    If the condition is a callable, it is used at runtime to dynamically\n    make the decision. This is useful for tests that may require costly\n    imports, to delay the cost until the test suite is actually executed.\n\n    Parameters\n    ----------\n    fail_condition : bool or callable\n        Flag to determine whether to mark the decorated test as a known\n        failure (if True) or not (if False).\n    msg : str, optional\n        Message to give on raising a KnownFailureTest exception.\n        Default is None.\n\n    Returns\n    -------\n    decorator : function\n        Decorator, which, when applied to a function, causes SkipTest\n        to be raised when `skip_condition` is True, and the function\n        to be called normally otherwise.\n\n    Notes\n    -----\n    The decorator itself is decorated with the ``nose.tools.make_decorator``\n    function in order to transmit function name, and various other metadata.\n\n    ' #NEWLINE# if ( msg is None ) : #NEWLINE# #INDENT# msg = 'Test skipped due to known failure' #NEWLINE# #UNINDENT# if isinstance ( fail_condition , collections . Callable ) : #NEWLINE# #INDENT# fail_val = ( lambda : fail_condition ( ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fail_val = ( lambda : fail_condition ) #NEWLINE# #UNINDENT# def knownfail_decorator( f ) : #NEWLINE# #INDENT# import nose #NEWLINE# def knownfailer( * args , **kwargs ) : #NEWLINE# #INDENT# if fail_val ( ) : #NEWLINE# #INDENT# raise KnownFailureTest ( msg ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return f ( * args , ** kwargs ) #NEWLINE# #UNINDENT# #UNINDENT# return nose . tools . make_decorator ( f ) ( knownfailer ) #NEWLINE# #UNINDENT# return knownfail_decorator