Skip to content

Commit dbcd9e2

Browse files
committed
Fix ftfont_test being run directly
ftfont_test uses font_test to run, but it was trying to import pygame.freetype for a version check without an explicit import (which pygame.freetype needs). Removed the dependency on pygame.freetype for the ftfont path.
1 parent 8d6e7f9 commit dbcd9e2

File tree

1 file changed

+17
-26
lines changed

1 file changed

+17
-26
lines changed

test/font_test.py

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ def test_font_method_should_raise_exception_after_quit(self):
876876
("set_underline", (True,)),
877877
("size", ("any Text",)),
878878
]
879-
version = pygame.freetype.get_version()
879+
skip_methods = set(("get_strikethrough", "set_strikethrough"))
880880
else:
881881
methods = [
882882
("get_height", tuple()),
@@ -897,30 +897,23 @@ def test_font_method_should_raise_exception_after_quit(self):
897897
("set_script", ("is it other text",)),
898898
("set_direction", ("is it text",)),
899899
]
900+
skip_methods = set()
900901
version = pygame.font.get_sdl_ttf_version()
901902
if version >= (2, 0, 18):
902903
methods.append(("get_point_size", tuple()))
903904
methods.append(("set_point_size", (34,)))
905+
else:
906+
skip_methods.add("get_point_size")
907+
skip_methods.add("set_point_size")
908+
skip_methods.add("point_size")
909+
910+
if version < (2, 20, 0):
911+
skip_methods.add("align")
904912

905913
font = pygame_font.Font(None, 10)
906914
actual_names = []
907915
for n in sorted(dir(font)):
908-
if n == "align" and version < (2, 20, 0):
909-
print(f"align skipped for sld ttf version {version} < 2.20.0")
910-
continue
911-
if n == "point_size" and version < (2, 0, 18):
912-
print(f"point_size skipped for sld ttf version {version} < 2.20.0")
913-
continue
914-
if n == "get_point_size" and version < (2, 0, 18):
915-
print(f"get_point_size skipped for sld ttf version {version} < 2.20.0")
916-
continue
917-
if n == "set_point_size" and version < (2, 0, 18):
918-
print(f"set_point_size skipped for sld ttf version {version} < 2.20.0")
919-
continue
920-
if (
921-
n == "get_strikethrough" or n == "set_strikethrough"
922-
) and pygame_font.__name__ == "pygame.ftfont":
923-
# this is only emulated in python
916+
if n in skip_methods:
924917
continue
925918
if n.startswith("_"):
926919
continue
@@ -979,7 +972,7 @@ def test_font_property_should_raise_exception_after_quit(self):
979972
("italic", True),
980973
("resolution", None),
981974
]
982-
version = pygame.freetype.get_version()
975+
skip_properties = set(("strikethrough",))
983976
else:
984977
properties = [
985978
("name", None),
@@ -989,24 +982,22 @@ def test_font_property_should_raise_exception_after_quit(self):
989982
("underline", True),
990983
("strikethrough", True),
991984
]
985+
skip_properties = set()
992986
version = pygame.font.get_sdl_ttf_version()
993987
if version >= (2, 20, 0):
994988
properties.append(("align", 1))
989+
else:
990+
skip_properties.add("align")
995991
if version >= (2, 0, 18):
996992
properties.append(("point_size", 1))
993+
else:
994+
skip_properties.add("point_size")
997995

998996
font = pygame_font.Font(None, 10)
999997
actual_names = []
1000998

1001999
for n in sorted(dir(font)):
1002-
if n == "align" and version < (2, 20, 0):
1003-
print(f"align skipped for sld ttf version {version} < 2.20.0")
1004-
continue
1005-
if n == "point_size" and version < (2, 0, 18):
1006-
print(f"point_size skipped for sld ttf version {version} < 2.0.18")
1007-
continue
1008-
if n == "strikethrough" and pygame_font.__name__ == "pygame.ftfont":
1009-
# this is only emulated in python
1000+
if n in skip_properties:
10101001
continue
10111002
if n.startswith("_"):
10121003
continue

0 commit comments

Comments
 (0)