def test_convert(self):
"""Ensure method convert() preserves the surface's class
When Surface is subclassed, the inherited convert() method will return
instances of the subclass. Non Surface fields are omitted, however.
This includes instance attributes.
"""
pygame.display.init()
try:
ms1 = self.MySurface((32, 32), 0, 24)
ms2 = ms1.convert(24)
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()
评论列表
文章目录