self = <swh.storage.tests.test_in_memory.TestInMemoryStorage object at 0x7f10155716a0>
swh_storage = <swh.storage.in_memory.InMemoryStorage object at 0x7f1016dec278>
sample_data = <swh.storage.tests.storage_data.StorageData object at 0x7f100d0627f0>
def test_release_add_no_author_date(self, swh_storage, sample_data):
full_release = sample_data.release
> release = attr.evolve(full_release, author=None, date=None)
.tox/py3/lib/python3.7/site-packages/swh/storage/tests/storage_tests.py:1293:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
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': None, 'date': None, 'message': b'synthetic release', 'name': b'v0.0.1', ...}
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 NoneType
.tox/py3/lib/python3.7/site-packages/attr/_funcs.py:347: TypeError
TEST RESULT
TEST RESULT
- Run At
- May 6 2021, 12:02 PM