def ExpectedFailure(reason, *exception_matchers):
 def decorator(test):
  @functools.wraps(test)
  def Wrapper(*args, **kwargs):
   try:
    test(*args, **kwargs)
   except Exception as test_exception:
    test_exception_message = ToUnicode(test_exception)
    try:
     for matcher in exception_matchers:
      assert_that(test_exception_message, matcher)
    except AssertionError:
     import traceback
     print((u'Test failed for the wrong reason: ' + traceback.format_exc()))
     raise test_exception
    raise nose.SkipTest(reason)
   else:
    raise AssertionError(u'Test was expected to fail: {0}'.format(reason))
  return Wrapper
 return decorator

def ExpectedFailure ( reason , * exception_matchers ) : def decorator ( test ) : @ functools . wraps ( test ) def Wrapper ( * args , ** kwargs ) : try : test ( * args , ** kwargs ) except Exception as test_exception : test_exception_message = ToUnicode ( test_exception ) try : for matcher in exception_matchers : assert_that ( test_exception_message , matcher ) except AssertionError : import traceback print ( ( u'Test failed for the wrong reason: ' + traceback . format_exc ( ) ) ) raise test_exception raise nose . SkipTest ( reason ) else : raise AssertionError ( u'Test was expected to fail: {0}' . format ( reason ) ) return Wrapper return decorator
defines a decorator to be attached to tests .