Skip to content

Commit 9e960b8

Browse files
committed
Add tests for deprecation
1 parent eecca9f commit 9e960b8

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

test/color_test.py

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,16 @@ def test_from_cmy(self):
782782
self.assertEqual(expected_cmy, cmy)
783783
self.assertEqual(expected_cmy, cmy_tuple)
784784

785+
with self.assertWarns(DeprecationWarning):
786+
self.assertEqual(
787+
expected_cmy, pygame.Color.from_cmy(0.5, 0.5, 0.5, "lel", "foo")
788+
)
789+
790+
with self.assertWarns(DeprecationWarning):
791+
self.assertEqual(
792+
expected_cmy, pygame.Color.from_cmy((0.5, 0.5, 0.5, 0.5))
793+
)
794+
785795
def test_from_hsva(self):
786796
hsva = pygame.Color.from_hsva(0, 100, 100, 100)
787797
hsva_tuple = pygame.Color.from_hsva((0, 100, 100, 100))
@@ -791,6 +801,16 @@ def test_from_hsva(self):
791801
self.assertEqual(expected_hsva, hsva)
792802
self.assertEqual(expected_hsva, hsva_tuple)
793803

804+
with self.assertWarns(DeprecationWarning):
805+
self.assertEqual(
806+
expected_hsva, pygame.Color.from_hsva(0, 100, 100, 100, "lel", "foo")
807+
)
808+
809+
with self.assertWarns(DeprecationWarning):
810+
self.assertEqual(
811+
expected_hsva, pygame.Color.from_hsva((0, 100, 100, 100, "lel"))
812+
)
813+
794814
def test_from_hsla(self):
795815
hsla = pygame.Color.from_hsla(0, 100, 100, 100)
796816
hsla_tuple = pygame.Color.from_hsla((0, 100, 100, 100))
@@ -800,6 +820,16 @@ def test_from_hsla(self):
800820
self.assertEqual(expected_hsla, hsla)
801821
self.assertEqual(expected_hsla, hsla_tuple)
802822

823+
with self.assertWarns(DeprecationWarning):
824+
self.assertEqual(
825+
expected_hsla, pygame.Color.from_hsla(0, 100, 100, 100, "lel")
826+
)
827+
828+
with self.assertWarns(DeprecationWarning):
829+
self.assertEqual(
830+
expected_hsla, pygame.Color.from_hsla((0, 100, 100, 100, "lel", "foo"))
831+
)
832+
803833
def test_from_i1i2i3(self):
804834
i1i2i3 = pygame.Color.from_i1i2i3(0, 0, 0)
805835
i1i2i3_tuple = pygame.Color.from_i1i2i3((0, 0, 0))
@@ -809,6 +839,16 @@ def test_from_i1i2i3(self):
809839
self.assertEqual(expected_i1i2i3, i1i2i3)
810840
self.assertEqual(expected_i1i2i3, i1i2i3_tuple)
811841

842+
with self.assertWarns(DeprecationWarning):
843+
self.assertEqual(
844+
expected_i1i2i3, pygame.Color.from_i1i2i3(0, 0, 0, "lel", "foo")
845+
)
846+
847+
with self.assertWarns(DeprecationWarning):
848+
self.assertEqual(
849+
expected_i1i2i3, pygame.Color.from_i1i2i3((0, 0, 0, 0))
850+
)
851+
812852
def test_normalize(self):
813853
c = pygame.Color(204, 38, 194, 55)
814854
self.assertEqual(c.r, 204)
@@ -989,6 +1029,12 @@ def test_cmy__sanity_testing_converted_should_equate_bar_rounding(self):
9891029
def test_i1i2i3__sanity_testing_converted_should_equate_bar_rounding(self):
9901030
self.colorspaces_converted_should_equate_bar_rounding("i1i2i3")
9911031

1032+
def test_colorspaces_deprecated_large_sequence(self):
1033+
c = pygame.Color("black")
1034+
for space in ("hsla", "hsva", "i1i2i3", "cmy"):
1035+
with self.assertWarns(DeprecationWarning):
1036+
setattr(c, space, (0, 0, 0, 0, "hehe 5th ignored member"))
1037+
9921038
################################################################################
9931039

9941040
def test_correct_gamma__verified_against_python_implementation(self):

0 commit comments

Comments
 (0)