diff --git a/mutapath/immutapath.py b/mutapath/immutapath.py index 29783a7..e26080c 100644 --- a/mutapath/immutapath.py +++ b/mutapath/immutapath.py @@ -23,6 +23,8 @@ from mashumaro.types import SerializableType except ImportError: SerializableType = object +except NotImplementedError: + SerializableType = object POSIX_ENABLED_DEFAULT = False diff --git a/tests/serializable.py b/tests/serializable.py deleted file mode 100644 index 7cab268..0000000 --- a/tests/serializable.py +++ /dev/null @@ -1,39 +0,0 @@ -from dataclasses import dataclass - -from mashumaro import DataClassDictMixin - -from mutapath import Path -from tests.helper import PathTest - - -@dataclass -class DataClass(DataClassDictMixin): - path: Path = Path() - - -class TestSerialization(PathTest): - - def test_empty_serialization(self): - expected = {'path': ''} - actual = DataClass().to_dict() - self.assertEqual(expected, actual) - - def test_serialization(self): - expected = {'path': "/A/B/test1.txt"} - actual = DataClass(Path("/A/B/test1.txt", posix=True)).to_dict() - self.assertEqual(expected, actual) - - def test_empty_deserialization(self): - expected = DataClass() - actual = DataClass().from_dict({'path': ''}) - self.assertEqual(expected, actual) - - def test_deserialization(self): - expected = DataClass(Path("/A/B/test1.txt", posix=True)) - actual = DataClass().from_dict({'path': "/A/B/test1.txt"}) - self.assertEqual(expected, actual) - - def test_deserialization_static(self): - expected = DataClass(Path("/A/B/test1.txt", posix=True)) - actual = DataClass.from_dict({'path': "/A/B/test1.txt"}) - self.assertEqual(expected, actual) diff --git a/tests/test_serializable.py b/tests/test_serializable.py new file mode 100644 index 0000000..261bae1 --- /dev/null +++ b/tests/test_serializable.py @@ -0,0 +1,45 @@ +from dataclasses import dataclass + +from mashumaro import DataClassDictMixin + +from mutapath import Path +from tests.helper import PathTest + +try: + from mashumaro.types import SerializableType +except ImportError: + SerializableType = object +except NotImplementedError: + SerializableType = object +else: + + @dataclass + class DataClass(DataClassDictMixin): + path: Path = Path() + + + class TestSerialization(PathTest): + def test_empty_serialization(self): + expected = {'path': ''} + actual = DataClass().to_dict() + self.assertEqual(expected, actual) + + def test_serialization(self): + expected = {'path': "/A/B/test1.txt"} + actual = DataClass(Path("/A/B/test1.txt", posix=True)).to_dict() + self.assertEqual(expected, actual) + + def test_empty_deserialization(self): + expected = DataClass() + actual = DataClass().from_dict({'path': ''}) + self.assertEqual(expected, actual) + + def test_deserialization(self): + expected = DataClass(Path("/A/B/test1.txt", posix=True)) + actual = DataClass().from_dict({'path': "/A/B/test1.txt"}) + self.assertEqual(expected, actual) + + def test_deserialization_static(self): + expected = DataClass(Path("/A/B/test1.txt", posix=True)) + actual = DataClass.from_dict({'path': "/A/B/test1.txt"}) + self.assertEqual(expected, actual)