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_dump_metanames(self):
assert attrdump(Mangle(12)) == {'va.lue': 12}
def test_basicdump(self):
assert attrdump(Person()) == {}
assert attrdump(Person('Alfio')) == {'name': 'Alfio'}
assert attrdump(Person('Alfio', '33')) == {'name': 'Alfio', 'address': '33'}
def test_nesteddump(self):
assert attrdump(
Students('advanced coursing', [
Person('Alfio'),
Person('Carmelo', 'via mulino'),
])) == {
'course': 'advanced coursing',
'students': [
{'name': 'Alfio'},
{'name': 'Carmelo', 'address': 'via mulino'},
]
def test_norepr(self):
@attr.s
class A:
i = attr.ib(type=int)
j = attr.ib(type=int, repr=False)
assert attrdump(A(1,1)) == {'i': 1}