mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-25 19:56:27 +01:00
31 lines
857 B
Python
31 lines
857 B
Python
from minecraft.exceptions import YggdrasilError
|
|
from minecraft.exceptions import DeserializationError, SerializationError
|
|
|
|
import unittest
|
|
|
|
|
|
class BaseRaiseExceptionTest(unittest.TestCase):
|
|
EXCEPTION_TO_TEST = Exception
|
|
|
|
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 RaiseYggdrasilError(BaseRaiseExceptionTest):
|
|
EXCEPTION_TO_TEST = YggdrasilError
|
|
|
|
|
|
class RaiseDeserializationError(BaseRaiseExceptionTest):
|
|
EXCEPTION_TO_TEST = DeserializationError
|
|
|
|
|
|
class RaiseSerializationError(BaseRaiseExceptionTest):
|
|
EXCEPTION_TO_TEST = SerializationError
|