How to use the typedload.dump function in typedload

To help you get started, we’ve selected a few typedload examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ltworf / typedload / tests / test_datadumper.py View on Github external
def test_kwargs(self):
        with self.assertRaises(ValueError):
            dump(1, handlers=[])
github ltworf / typedload / tests / test_datadumper.py View on Github external
def test_dump(self):
        A = NamedTuple('A',[('a', int), ('b', str)])
        assert dump(A(1, '12')) == {'a': 1, 'b': '12'}
github ltworf / typedload / tests / test_dataclass.py View on Github external
def test_factory_dump(self):
        @dataclass
        class A:
            a: int
            b: List[int] = field(default_factory=list)

        assert dump(A(3)) == {'a': 3}
        assert dump(A(12), hidedefault=False) == {'a': 12, 'b': []}
github ltworf / typedload / tests / test_dataclass.py View on Github external
def test_factory_dump(self):
        @dataclass
        class A:
            a: int
            b: List[int] = field(default_factory=list)

        assert dump(A(3)) == {'a': 3}
        assert dump(A(12), hidedefault=False) == {'a': 12, 'b': []}
github ltworf / typedload / tests / test_dataclass.py View on Github external
def test_mangle_load(self):
        @dataclass
        class Mangle:
            value: int = field(metadata={'name': 'va.lue'})
        assert load({'va.lue': 1}, Mangle) == Mangle(1)
        assert dump(Mangle(1)) == {'va.lue': 1}
github ltworf / typedload / tests / test_dataclass.py View on Github external
def test_dump(self):
        @dataclass
        class A:
            a: int
            b: int = 0

        assert dump(A(12)) == {'a': 12}
        assert dump(A(12), hidedefault=False) == {'a': 12, 'b': 0}
github ltworf / typedload / tests / test_dataclass.py View on Github external
def test_dump(self):
        @dataclass
        class A:
            a: int
            b: int = 0

        assert dump(A(12)) == {'a': 12}
        assert dump(A(12), hidedefault=False) == {'a': 12, 'b': 0}
github ltworf / typedload / tests / test_datadumper.py View on Github external
def test_enum(self):
        assert load(dump(EnumA.C), EnumA) == EnumA.C
github ltworf / localslackirc / slack.py View on Github external
def get_status(self) -> bytes:
        '''
        A status string that will be passed back when this is started again
        '''
        return json.dumps(dump(self._status), ensure_ascii=True).encode('ascii')