Skip to content

Commit

Permalink
fix(tests): on python 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
matfax committed Oct 24, 2019
1 parent e6ce623 commit a929290
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 39 deletions.
2 changes: 2 additions & 0 deletions mutapath/immutapath.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
from mashumaro.types import SerializableType
except ImportError:
SerializableType = object
except NotImplementedError:
SerializableType = object

POSIX_ENABLED_DEFAULT = False

Expand Down
39 changes: 0 additions & 39 deletions tests/serializable.py

This file was deleted.

45 changes: 45 additions & 0 deletions tests/test_serializable.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit a929290

Please sign in to comment.