You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Object with __init__ that carries required non-default arguments are not supported
Example
class ObjectMapperTest(unittest.TestCase):
"""
Unit tests for the `ObjectMapper` module.
"""
@dataclass
class FromTestDataClass:
a: int
b: str
@dataclass
class ToTestDataClass:
a: int
b: str
def test_mapping_creation_without_mappings_correct_using_dataclass(self):
""" Test mapping creation without mappings with dataclass"""
# Arrange
from_class = FromTestClass()
mapper = ObjectMapper()
mapper.create_map(FromTestDataClass, ToTestDataClass)
# Act
result = mapper.map(FromTestDataClass(a=1, b='2'))
# Assert
self.assertTrue(isinstance(result, ToTestDataClass), "Target types must be same")
self.assertEqual(result.name, from_class.name, "Name mapping must be equal")
self.assertEqual(result, ToTestDataClass(a=1, b='2'), "Class instance must be equal")
The text was updated successfully, but these errors were encountered:
@dataclass
is a pretty good feature and unfortunatelly is not supported.object-mapper/mapper/object_mapper.py
Line 171 in 9d62e9b
Example
The text was updated successfully, but these errors were encountered: