def test_revision_extra_headers_type_error():
rev_dict = revision_example.copy()
rev_dict.pop("id")
rev = Revision.from_dict(rev_dict)
orig_rev_dict = attr.asdict(rev, recurse=False)
orig_rev_dict["metadata"] = {
"something": "somewhere",
"some other thing": "stranger",
}
extra_headers = (
("header1", b"value1"),
(b"header2", 42),
("header1", "again"),
)
# check headers one at a time
# if given as extra_header
for extra_header in extra_headers:
rev_dict = copy.deepcopy(orig_rev_dict)
rev_dict["extra_headers"] = (extra_header,)
with pytest.raises(AttributeTypeError):
Revision(**rev_dict)
# if given as metadata
for extra_header in extra_headers:
rev_dict = copy.deepcopy(orig_rev_dict)
rev_dict["metadata"]["extra_headers"] = (extra_header,)
with pytest.raises(AttributeTypeError):
> Revision(**rev_dict)
.tox/py3/lib/python3.7/site-packages/swh/model/tests/test_model.py:541:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<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'...]\xb5\xec\xb3\x1e\x9d\xe8\x08',), id=b'\xbc\x01\x95\xaa\xd0\xda\xa2\xad[\rv\xcc\xe2+\x16{\xc3CU\x90', 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:483: AttributeError
TEST RESULT
TEST RESULT
- Run At
- Jul 7 2020, 11:53 AM