Пример #1
0
 def test_matches_same_args(self):
     matcher = MatchesException(Exception("foo"))
     try:
         raise Exception("foo")
     except Exception:
         error = sys.exc_info()
     mismatch = matcher.match(error)
     self.assertEqual(None, mismatch)
Пример #2
0
 def test_does_not_match_different_args(self):
     matcher = MatchesException(Exception("foo"))
     try:
         raise Exception("bar")
     except Exception:
         error = sys.exc_info()
     mismatch = matcher.match(error)
     self.assertNotEqual(None, mismatch)
     self.assertEqual(
         "Exception('bar',) has different arguments to Exception('foo',).",
         mismatch.describe())
Пример #3
0
 def test_does_not_match_different_exception_class(self):
     matcher = MatchesException(ValueError("foo"))
     try:
         raise Exception("foo")
     except Exception:
         error = sys.exc_info()
     mismatch = matcher.match(error)
     self.assertNotEqual(None, mismatch)
     self.assertEqual(
         "<type 'exceptions.Exception'> is not a "
         "<type 'exceptions.ValueError'>",
         mismatch.describe())