test_functools32.py 文件源码

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

项目:deb-python-functools32 作者: openstack 项目源码 文件源码
def test_attributes(self):
        p = self.thetype(capture, 1, 2, a=10, b=20)
        # attributes should be readable
        self.assertEqual(p.func, capture)
        self.assertEqual(p.args, (1, 2))
        self.assertEqual(p.keywords, dict(a=10, b=20))
        # attributes should not be writable
        if not isinstance(self.thetype, type):
            return
        if "__pypy__" in sys.modules:
            raise unittest.SkipTest("In the PyPy execution environment")
        self.assertRaises(TypeError, setattr, p, 'func', map)
        self.assertRaises(TypeError, setattr, p, 'args', (1, 2))
        self.assertRaises(TypeError, setattr, p, 'keywords', dict(a=1, b=2))

        p = self.thetype(hex)
        try:
            del p.__dict__
        except TypeError:
            pass
        else:
            self.fail('partial object allowed __dict__ to be deleted')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号