self = <swh.storage.tests.test_api_client.TestStorageApi object at 0x7f12139e9748>
swh_storage = <RemoteStorage url=mock://example.com/>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f12139e9080>
def test_release_add_name_clash(self, swh_storage, sample_data):
release, release2 = [
attr.evolve(
c,
author=Person(
fullname=b"John Doe <john.doe@example.com>",
name=b"John Doe",
email=b"john.doe@example.com",
),
)
> for c in sample_data.releases[:2]
]
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:1331:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:1331: in <listcomp>
for c in sample_data.releases[:2]
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
inst = Release(name=b'v0.0.1', message=b'synthetic release', target=b'\x01\xa7\x11O6\xfd\xdd^\xf2Q\x1b,\xad\xda#zh\xad\xbb\x1...ds=0), offset=42, negative_utc=False), metadata=None, id=b'\xf7\xf2"\t:\x18\xec`\xd7\x81\x07\n\xbe\xc4\xa60\xc8P\xb87')
changes = {'author': Person(fullname=b'John Doe <john.doe@example.com>', name=b'John Doe', email=b'john.doe@example.com'), 'message': b'synthetic release', 'name': b'v0.0.1', 'synthetic': True, ...}
cls = <class 'swh.model.model.Release'>
attrs = (Attribute(name='name', default=NOTHING, validator=<function type_validator.<locals>._validator at 0x7f121880d1e0>, re...rue, metadata=mappingproxy({}), type=<class 'bytes'>, converter=None, kw_only=False, inherited=False, on_setattr=None))
a = Attribute(name='author', default=None, validator=_AndValidator(_validators=(<function type_validator.<locals>._validat..., type=typing.Union[swh.model.model.Person, NoneType], converter=None, kw_only=False, inherited=False, on_setattr=None)
attr_name = 'author', init_name = 'author'
value = Person(fullname=b'olasd <nic@olasd.fr>', name=b'olasd', email=b'nic@olasd.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