def test_rgba (self): c = Color (0) self.assertEqual (c.r, 0) self.assertEqual (c.g, 0) self.assertEqual (c.b, 0) self.assertEqual (c.a, 0) # Test simple assignments c.r = 123 self.assertEqual (c.r, 123) self.assertRaises (ValueError, _assignr, c, 537) self.assertEqual (c.r, 123) self.assertRaises (ValueError, _assignr, c, -3) self.assertEqual (c.r, 123) c.g = 55 self.assertEqual (c.g, 55) self.assertRaises (ValueError, _assigng, c, 348) self.assertEqual (c.g, 55) self.assertRaises (ValueError, _assigng, c, -44) self.assertEqual (c.g, 55) c.b = 77 self.assertEqual (c.b, 77) self.assertRaises (ValueError, _assignb, c, 256) self.assertEqual (c.b, 77) self.assertRaises (ValueError, _assignb, c, -12) self.assertEqual (c.b, 77) c.a = 255 self.assertEqual (c.a, 255) self.assertRaises (ValueError, _assigna, c, 312) self.assertEqual (c.a, 255) self.assertRaises (ValueError, _assigna, c, -10) self.assertEqual (c.a, 255)
def test_pygame2_base_Color_r(self): # __doc__ (as of 2008-10-17) for pygame2.base.Color.r: # Gets or sets the red value of the Color. c = Color (100, 100, 100) self.assertEqual (c.r, 100) c = Color (100, 100, 100, 100) self.assertEqual (c.r, 100) c = Color (100, 100, 100) self.assertEqual (c.r, 100) c.r = 200 self.assertEqual (c.r, 200) c.r += 22 self.assertEqual (c.r, 222) c = Color (0xAABBCCDD) self.assertEqual (c.r, 0xBB) c = Color ("0xBBCCDD") self.assertEqual (c.r, 0xBB) c = Color ("0xAABBCCDD") self.assertEqual (c.r, 0xAA) c = Color ("#AABBCCDD") self.assertEqual (c.r, 0xAA) c = Color ("#BBCCDD") self.assertEqual (c.r, 0xBB) c = Color ("red") self.assertEqual (c.r, 255) c = Color ("blue") self.assertEqual (c.r, 0)