test_AttributeDict.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:pep 作者: pepkit 项目源码 文件源码
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)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号