def test_touch_privileged_metadata_item(self, funcname,
name_metadata_item):
""" AttributeDict has a few metadata members that may not be set. """
# Create AttributeDict and ensure it has the target item.
ad = AttributeDict(dict(basic_entries()))
assert hasattr(ad, name_metadata_item)
# If current test parameter is a setter, it needs a value argument.
dummy_value = "this_will_fail"
touch = getattr(ad, funcname)
args = (name_metadata_item, )
# Make the actual call under test.
if funcname in ["__setattr__", "__setitem__"]:
pytest.xfail(
"Since {} is recursive, it's difficult to prohibit "
"post-construction attempts to set metadata. It may "
"not even be desirable".format(AttributeDict.__name__))
args += (dummy_value, )
with pytest.raises(_MetadataOperationException):
touch.__call__(*args)
评论列表
文章目录