Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added unit test for surface.get_colorkey(). Closes #1801 #1881

Merged
merged 8 commits into from Jun 3, 2020
32 changes: 24 additions & 8 deletions test/surface_test.py
Expand Up @@ -1000,14 +1000,30 @@ def test_get_clip(self):
rectangle = s.get_clip()
self.assertEqual(rectangle, (0, 0, 800, 600))

def todo_test_get_colorkey(self):
surf = pygame.surface((2, 2), 0, 24)
self.assertIsNone(surf.get_colorykey())
colorkey = pygame.Color(20, 40, 60)
surf.set_colorkey(colorkey)
ck = surf.get_colorkey()
self.assertIsInstance(ck, pygame.Color)
self.assertEqual(ck, colorkey)
def test_get_colorkey(self):
# if set_colorkey is not used
s = pygame.Surface((800, 600))
self.assertIsNone(s.get_colorkey())

# if set_colorkey is used
s.set_colorkey(None)
self.assertIsNone(s.get_colorkey())

# setting up remainder of tests...
r, g, b, a = 20, 40, 60, 12
colorkey = pygame.Color(r, g, b)
s.set_colorkey(colorkey)

self.assertEqual(s.get_colorkey(), (r, g, b, 255))

s.set_colorkey(colorkey, pygame.RLEACCEL)
self.assertEqual(s.get_colorkey(), (r, g, b, 255))

s.set_colorkey(pygame.Color(r + 1, g + 1, b + 1))
self.assertNotEqual(s.get_colorkey(), (r, g, b, 255))

s.set_colorkey(pygame.Color(r, g, b, a)) # regardless of whether alpha is not 255, colorkey returned from surface is always 255
self.assertEqual(s.get_colorkey(), (r, g, b, 255))

def test_get_height(self):
sizes = ((1, 1), (119, 10), (10, 119), (1, 1000), (1000, 1), (1000, 1000))
Expand Down