Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_kwargs(self):
with self.assertRaises(ValueError):
dump(1, handlers=[])
def test_dump(self):
A = NamedTuple('A',[('a', int), ('b', str)])
assert dump(A(1, '12')) == {'a': 1, 'b': '12'}
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': []}
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': []}
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}
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}
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}
def test_enum(self):
assert load(dump(EnumA.C), EnumA) == EnumA.C
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')