mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-22 02:08:56 +01:00
Abstraction in exceptions tests
This commit is contained in:
parent
a589c1e61f
commit
8ca5c7f35f
@ -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