surface_test.py 文件源码

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

项目:Projects 作者: it2school 项目源码 文件源码
def test_convert_alpha(self):
        """Ensure method convert_alpha() preserves the surface's class

        When Surface is subclassed, the inherited convert_alpha() method will
        return instances of the subclass. Non Surface fields are omitted,
        however. This includes instance attributes.
        """
        pygame.display.init()
        try:
            pygame.display.set_mode((40, 40))
            s = pygame.Surface((32, 32), pygame.SRCALPHA, 16)
            ms1 = self.MySurface((32, 32), pygame.SRCALPHA, 32)
            ms2 = ms1.convert_alpha(s)
            self.assertTrue(ms2 is not ms1)
            self.assertTrue(isinstance(ms2, self.MySurface))
            self.assertTrue(ms1.an_attribute)
            self.assertRaises(AttributeError, getattr, ms2, "an_attribute")
        finally:
            pygame.display.quit()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号