self = <swh.storage.tests.test_in_memory.TestInMemoryStorage object at 0x7f100b741518>
swh_storage = <swh.storage.in_memory.InMemoryStorage object at 0x7f1213a3e5f8>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f100b734588>
def test_revision_add_name_clash(self, swh_storage, sample_data):
revision, revision2 = sample_data.revisions[:2]
revision1 = attr.evolve(
revision,
author=Person(
fullname=b"John Doe <john.doe@example.com>",
name=b"John Doe",
> email=b"john.doe@example.com",
),
)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:970:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
inst = Revision(message=b'hello', author=Person(fullname=b'Nicolas Dandrimont <nicolas@example.com> ', name=b'Nicolas Dandrim...xbb\x12', extra_headers=((b'gpgsig', b'test123'), (b'mergetag', b'foo\\bar'), (b'mergetag', b'"\xaf\x89\x80\x01\x00')))
changes = {'author': Person(fullname=b'John Doe <john.doe@example.com>', name=b'John Doe', email=b'john.doe@example.com'), 'message': b'hello'}
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='author', default=NOTHING, validator=<function type_validator.<locals>._validator at 0x7f1218812598>, r...ppingproxy({}), type=<class 'swh.model.model.Person'>, converter=None, kw_only=False, inherited=False, on_setattr=None)
attr_name = 'author', init_name = 'author'
value = Person(fullname=b'Nicolas Dandrimont <nicolas@example.com> ', name=b'Nicolas Dandrimont', email=b'nicolas@example.com')
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