def assertRaisesExactly(cls, fn, *args, **kwargs):
 try:
  fn(*args, **kwargs)
 except Exception as e:
  assert (e.__class__ == cls), ('got %s, expected %s' % (e.__class__.__name__, cls.__name__))
 else:
  raise AssertionError(('%s not raised' % cls))

def assertRaisesExactly ( cls , fn , * args , ** kwargs ) : try : fn ( * args , ** kwargs ) except Exception as e : assert ( e . __class__ == cls ) , ( 'got %s, expected %s' % ( e . __class__ . __name__ , cls . __name__ ) ) else : raise AssertionError ( ( '%s not raised' % cls ) )
unlike the standard assertraises .