mirror of
https://github.com/ammaraskar/pyCraft.git
synced 2024-11-22 10:15:55 +01:00
Added exceptions for serialization and deserialization. These will come in handy later
This commit is contained in:
parent
6daca43748
commit
658c451930
@ -5,5 +5,19 @@ Contains the `Exceptions` used by this library.
|
||||
|
||||
class YggdrasilError(Exception):
|
||||
"""
|
||||
Base `Exception` for the Yggdrasil authentication service.
|
||||
Base ``Exception`` for the Yggdrasil authentication service.
|
||||
"""
|
||||
|
||||
|
||||
class DeserializationError(Exception):
|
||||
"""
|
||||
``Exception`` raised when something went wrong during the deserialization
|
||||
process.
|
||||
"""
|
||||
|
||||
|
||||
class SerializationError(Exception):
|
||||
"""
|
||||
``Exception`` raised when something went wrong during the serialization
|
||||
process.
|
||||
"""
|
||||
|
@ -1,4 +1,5 @@
|
||||
from minecraft.exceptions import YggdrasilError
|
||||
from minecraft.exceptions import DeserializationError, SerializationError
|
||||
|
||||
import unittest
|
||||
|
||||
@ -13,3 +14,27 @@ class RaiseYggdrasilError(unittest.TestCase):
|
||||
raise YggdrasilError("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 RaiseSerializationError(unittest.TestCase):
|
||||
def test_raise_serialization_error(self):
|
||||
with self.assertRaises(SerializationError):
|
||||
raise SerializationError
|
||||
|
||||
def test_raise_serialization_error_message(self):
|
||||
with self.assertRaises(SerializationError) as e:
|
||||
raise SerializationError("Error!")
|
||||
|
||||
self.assertEqual(str(e.exception), "Error!")
|
||||
|
Loading…
Reference in New Issue
Block a user