self = <swh.storage.tests.storage_tests.TestStorage object at 0x7f111c236908>
swh_storage = <swh.storage.postgresql.storage.Storage object at 0x7f10f85d1978>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f10575c93c8>
def test_person_fullname_unicity(self, swh_storage, sample_data):
revision, rev2 = sample_data.revisions[0:2]
# create a revision with same committer fullname but wo name and email
revision2 = attr.evolve(
rev2,
committer=Person(
> fullname=revision.committer.fullname, name=None, email=None
),
)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:2834:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
inst = Revision(message=b'hello again', author=Person(fullname=b'Roberto Dicosmo <roberto@example.com>', name=b'Roberto Dicos...x1b,\xad\xda#zh\xad\xbb\x12',), id=b'\xa6F\xdd\x94\xc9\x12\x82\x96Y\xb2*\x1e~\x14=/\xa5\xeb\xde\x1b', extra_headers=())
changes = {'author': Person(fullname=b'Roberto Dicosmo <roberto@example.com>', name=b'Roberto Dicosmo', email=b'roberto@example....er': Person(fullname=b'St\xc3fano Zacchiroli <stefano@example.com>', name=None, email=None), 'message': b'hello again'}
cls = <class 'swh.model.model.Revision'>
attrs = (Attribute(name='message', default=NOTHING, validator=<function type_validator.<locals>._validator at 0x7f1218812510>,..., ...], converter=<function tuplify_extra_headers at 0x7f12187efae8>, kw_only=False, inherited=False, on_setattr=None))
a = Attribute(name='committer', default=NOTHING, validator=<function type_validator.<locals>._validator at 0x7f1218812620>...ppingproxy({}), type=<class 'swh.model.model.Person'>, converter=None, kw_only=False, inherited=False, on_setattr=None)
attr_name = 'committer', init_name = 'committer'
value = Person(fullname=b'tony <ar@dumont.fr>', name=b'tony', email=b'ar@dumont.fr')
def evolve(inst, **changes):
"""
Create a new instance, based on *inst* with *changes* applied.
:param inst: Instance of a class with ``attrs`` attributes.
:param changes: Keyword changes in the new copy. Nested ``attrs`` classes
can be updated by passing (nested) dicts of values.
:return: A copy of inst with *changes* incorporated.
:raise TypeError: If *attr_name* couldn't be found in the class
``__init__``.
:raise attr.exceptions.NotAnAttrsClassError: If *cls* is not an ``attrs``
class.
.. versionadded:: 17.1.0
"""
cls = inst.__class__
attrs = fields(cls)
for a in attrs:
if not a.init:
continue
attr_name = a.name # To deal with private attributes.
init_name = attr_name if attr_name[0] != "_" else attr_name[1:]
value = getattr(inst, attr_name)
if init_name not in changes:
# Add original value to changes
changes[init_name] = value
elif has(value):
# Evolve nested attrs classes
> changes[init_name] = evolve(value, **changes[init_name])
E TypeError: evolve() argument after ** must be a mapping, not Person
.tox/py3/lib/python3.7/site-packages/attr/_funcs.py:347: TypeError
TEST RESULT
TEST RESULT
- Run At
- May 6 2021, 12:02 PM