def test_revision_extra_headers_in_metadata_from_dict():
rev_dict = revision_example.copy()
rev_dict.pop("id")
rev_dict["metadata"] = {
"something": "somewhere",
"some other thing": "stranger",
}
extra_headers = (
(b"header1", b"value1"),
(b"header2", b"42"),
(b"header3", b"should I?\nmaybe\x00\xff"),
(b"header1", b"again"),
)
# check the bw-compat init hook does the job
rev_dict["metadata"]["extra_headers"] = extra_headers
> rev_model = Revision.from_dict(rev_dict)
.tox/py3/lib/python3.7/site-packages/swh/model/tests/test_model.py:587:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
.tox/py3/lib/python3.7/site-packages/swh/model/model.py:507: in from_dict
**d,
<attrs generated init swh.model.model.Revision>:28: in __init__
self.__attrs_post_init__()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = Revision(message=b'Linux 4.2-rc2\n', author=Person(fullname=b'Linus Torvalds <torvalds@linux-foundation.org>', name=b'...4]\xb5\xec\xb3\x1e\x9d\xe8\x08',), id=b'\xe6\xdcC\xfb0,\xcd)\xba\xb9\x1b(\xcf\x0e\xf7[\x14\x8f\xd5>', extra_headers=())
def __attrs_post_init__(self):
super().__attrs_post_init__()
# ensure metadata is a deep copy of whatever was given, and if needed
# extract extra_headers from there
if self.metadata:
metadata = deepcopy(self.metadata)
if not self.extra_headers and "extra_headers" in metadata:
object.__setattr__(
self,
"extra_headers",
> tuplify_extra_headers(metadata.pop("extra_headers")),
)
E AttributeError: 'ImmutableDict' object has no attribute 'pop'
.tox/py3/lib/python3.7/site-packages/swh/model/model.py:480: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Jul 7 2020, 11:51 AM