Skip to content

Commit

Permalink
Merge pull request #2763 from Starbuck5/fix-ftfont-test
Browse files Browse the repository at this point in the history
Fix ftfont_test being run directly
  • Loading branch information
Starbuck5 authored Mar 28, 2024
2 parents be49061 + 4c17b2f commit 98fc54d
Showing 1 changed file with 17 additions and 26 deletions.
43 changes: 17 additions & 26 deletions test/font_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -876,7 +876,7 @@ def test_font_method_should_raise_exception_after_quit(self):
("set_underline", (True,)),
("size", ("any Text",)),
]
version = pygame.freetype.get_version()
skip_methods = {"get_strikethrough", "set_strikethrough"}
else:
methods = [
("get_height", tuple()),
Expand All @@ -897,30 +897,23 @@ def test_font_method_should_raise_exception_after_quit(self):
("set_script", ("is it other text",)),
("set_direction", ("is it text",)),
]
skip_methods = set()
version = pygame.font.get_sdl_ttf_version()
if version >= (2, 0, 18):
methods.append(("get_point_size", tuple()))
methods.append(("set_point_size", (34,)))
else:
skip_methods.add("get_point_size")
skip_methods.add("set_point_size")
skip_methods.add("point_size")

if version < (2, 20, 0):
skip_methods.add("align")

font = pygame_font.Font(None, 10)
actual_names = []
for n in sorted(dir(font)):
if n == "align" and version < (2, 20, 0):
print(f"align skipped for sld ttf version {version} < 2.20.0")
continue
if n == "point_size" and version < (2, 0, 18):
print(f"point_size skipped for sld ttf version {version} < 2.20.0")
continue
if n == "get_point_size" and version < (2, 0, 18):
print(f"get_point_size skipped for sld ttf version {version} < 2.20.0")
continue
if n == "set_point_size" and version < (2, 0, 18):
print(f"set_point_size skipped for sld ttf version {version} < 2.20.0")
continue
if (
n == "get_strikethrough" or n == "set_strikethrough"
) and pygame_font.__name__ == "pygame.ftfont":
# this is only emulated in python
if n in skip_methods:
continue
if n.startswith("_"):
continue
Expand Down Expand Up @@ -979,7 +972,7 @@ def test_font_property_should_raise_exception_after_quit(self):
("italic", True),
("resolution", None),
]
version = pygame.freetype.get_version()
skip_properties = {"strikethrough"}
else:
properties = [
("name", None),
Expand All @@ -989,24 +982,22 @@ def test_font_property_should_raise_exception_after_quit(self):
("underline", True),
("strikethrough", True),
]
skip_properties = set()
version = pygame.font.get_sdl_ttf_version()
if version >= (2, 20, 0):
properties.append(("align", 1))
else:
skip_properties.add("align")
if version >= (2, 0, 18):
properties.append(("point_size", 1))
else:
skip_properties.add("point_size")

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

for n in sorted(dir(font)):
if n == "align" and version < (2, 20, 0):
print(f"align skipped for sld ttf version {version} < 2.20.0")
continue
if n == "point_size" and version < (2, 0, 18):
print(f"point_size skipped for sld ttf version {version} < 2.0.18")
continue
if n == "strikethrough" and pygame_font.__name__ == "pygame.ftfont":
# this is only emulated in python
if n in skip_properties:
continue
if n.startswith("_"):
continue
Expand Down

0 comments on commit 98fc54d

Please sign in to comment.