-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
39 additions
and
39 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import sys | ||
from dataclasses import dataclass | ||
|
||
from mashumaro import DataClassDictMixin | ||
|
||
from mutapath import Path | ||
from tests.helper import PathTest | ||
|
||
if sys.version_info == (3, 7): | ||
@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) |