コード例 #1
0
 def test_raise_with_proper_code_and_args(self):
     """
     Ensure that the requested exception is raised.
     """
     with self.assertRaises(ResultException) as cm:
         raise ResultException(102, 'foo', 'bar')
     self.assertEqual(cm.exception.status_code, 102)
コード例 #2
0
 def test_raise_using_invalid_code(self):
     """
     Ensure that a default exception/code is used if invalid code is provided.
     """
     with self.assertRaises(ResultException) as cm:
         raise ResultException('foo')
     self.assertEqual(cm.exception.status_code, 100)
コード例 #3
0
 def test_raise_without_code(self):
     """
     Ensure that a default exception/code is used if none is provided.
     """
     with self.assertRaises(ResultException) as cm:
         raise ResultException()
     self.assertEqual(cm.exception.status_code, 100)
コード例 #4
0
 def test_raise_without_args(self):
     """
     Ensure that a default exception/code is used if the message requested
     by the code provided requires an argument list and none is provided.
     """
     with self.assertRaises(ResultException) as cm:
         raise ResultException(101)
     self.assertEqual(cm.exception.status_code, 100)
コード例 #5
0
 def test_raise_without_insufficient_args(self):
     """
     Ensure that a default exception/code is used if the message requested
     by the code provided requires an argument list but the one provided
     does not contain the correct amount of arguments.
     """
     with self.assertRaises(ResultException) as cm:
         raise ResultException(102, 'foo')
     self.assertEqual(cm.exception.status_code, 100)