def raises(*exceptions):
 valid = ' or '.join([e.__name__ for e in exceptions])
 def decorate(func):
  name = func.__name__
  def newfunc(*arg, **kw):
   try:
    func(*arg, **kw)
   except exceptions:
    pass
   else:
    message = '{}() did not raise {}'.format(name, valid)
    raise AssertionError(message)
  newfunc = make_decorator(func)(newfunc)
  return newfunc
 return decorate

def raises ( * exceptions ) : valid = ' or ' . join ( [ e . __name__ for e in exceptions ] ) def decorate ( func ) : name = func . __name__ def newfunc ( * arg , ** kw ) : try : func ( * arg , ** kw ) except exceptions : pass else : message = '{}() did not raise {}' . format ( name , valid ) raise AssertionError ( message ) newfunc = make_decorator ( func ) ( newfunc ) return newfunc return decorate
raise :exc:assertionerror if func does not raise *exc* .