mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-22 10:15:55 +01:00
Abstraction in exceptions tests
This commit is contained in:
parent
658c451930
commit
3e4c2ddebf
@ -4,37 +4,27 @@ from minecraft.exceptions import DeserializationError, SerializationError
|
||||
import unittest
|
||||
|
||||
|
||||
class RaiseYggdrasilError(unittest.TestCase):
|
||||
def test_raise_yggdrasil_error(self):
|
||||
with self.assertRaises(YggdrasilError):
|
||||
raise YggdrasilError
|
||||
class BaseRaiseExceptionTest(unittest.TestCase):
|
||||
EXCEPTION_TO_TEST = Exception
|
||||
|
||||
def test_raise_yggdrasil_error_message(self):
|
||||
with self.assertRaises(YggdrasilError) as e:
|
||||
raise YggdrasilError("Error!")
|
||||
def test_raise_error(self):
|
||||
with self.assertRaises(self.EXCEPTION_TO_TEST):
|
||||
raise self.EXCEPTION_TO_TEST
|
||||
|
||||
def test_raise_error_message(self):
|
||||
with self.assertRaises(self.EXCEPTION_TO_TEST) as e:
|
||||
raise self.EXCEPTION_TO_TEST("Error!")
|
||||
|
||||
self.assertEqual(str(e.exception), "Error!")
|
||||
|
||||
|
||||
class RaiseDeserializationError(unittest.TestCase):
|
||||
def test_raise_deserialization_error(self):
|
||||
with self.assertRaises(DeserializationError):
|
||||
raise DeserializationError
|
||||
|
||||
def test_raise_deserialization_error_message(self):
|
||||
with self.assertRaises(DeserializationError) as e:
|
||||
raise DeserializationError("Error!")
|
||||
|
||||
self.assertEqual(str(e.exception), "Error!")
|
||||
class RaiseYggdrasilError(BaseRaiseExceptionTest):
|
||||
EXCEPTION_TO_TEST = YggdrasilError
|
||||
|
||||
|
||||
class RaiseSerializationError(unittest.TestCase):
|
||||
def test_raise_serialization_error(self):
|
||||
with self.assertRaises(SerializationError):
|
||||
raise SerializationError
|
||||
class RaiseDeserializationError(BaseRaiseExceptionTest):
|
||||
EXCEPTION_TO_TEST = DeserializationError
|
||||
|
||||
def test_raise_serialization_error_message(self):
|
||||
with self.assertRaises(SerializationError) as e:
|
||||
raise SerializationError("Error!")
|
||||
|
||||
self.assertEqual(str(e.exception), "Error!")
|
||||
class RaiseSerializationError(BaseRaiseExceptionTest):
|
||||
EXCEPTION_TO_TEST = SerializationError
|
||||
|
Loading…
Reference in New Issue
Block a user