Skip to content

Commit

Permalink
[test] Remove message verification of the AttributeError
Browse files Browse the repository at this point in the history
It doesn't serve any purpose. Also, it depend on the os language. Ex: "can't set attribute" on github action, but locally, it is "property 'font_type' of 'VariableFontFace' object has no setter"
  • Loading branch information
moi15moi committed Jan 23, 2024
1 parent 15b4e25 commit a29ffe8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 19 deletions.
6 changes: 3 additions & 3 deletions tests/font/test_font_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,21 @@ def test_filename_property():
font_file = FontFile(filename, font_faces)
with pytest.raises(AttributeError) as exc_info:
font_file.filename = filename
assert str(exc_info.value) == "property 'filename' of 'FontFile' object has no setter"


def test_font_faces_property():
font_faces = [VariableFontFace(0, [Name("test", Language.get("en"))], [], [], 400, False, FontType.TRUETYPE, {})]
font_file = FontFile(filename, font_faces)
with pytest.raises(AttributeError) as exc_info:
font_file.font_faces = font_faces
assert str(exc_info.value) == "property 'font_faces' of 'FontFile' object has no setter"


def test_last_loaded_time_property():
font_faces = [VariableFontFace(0, [Name("test", Language.get("en"))], [], [], 400, False, FontType.TRUETYPE, {})]
font_file = FontFile(filename, font_faces)
with pytest.raises(AttributeError) as exc_info:
font_file.last_loaded_time = 1000
assert str(exc_info.value) == "property 'last_loaded_time' of 'FontFile' object has no setter"


def test_from_font_path():
font_mac_platform = Path(os.path.join(os.path.dirname(dir_path), "file", "fonts", "font_mac.TTF"))
Expand Down
7 changes: 0 additions & 7 deletions tests/font/test_normal_font_face.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,55 +56,48 @@ def test_font_index_property():
font_index = 1
with pytest.raises(AttributeError) as exc_info:
font.font_index = font_index
assert str(exc_info.value) == "property 'font_index' of 'NormalFontFace' object has no setter"


def test_family_names_property():
font = NormalFontFace(0, [Name("test", Language.get("en"))], [], 400, False, False, FontType.TRUETYPE)
family_names = [Name("test", Language.get("en"))]
with pytest.raises(AttributeError) as exc_info:
font.family_names = family_names
assert str(exc_info.value) == "property 'family_names' of 'NormalFontFace' object has no setter"


def test_exact_names_property():
font = NormalFontFace(0, [Name("test", Language.get("en"))], [], 400, False, False, FontType.TRUETYPE)
exact_names = [Name("test", Language.get("en"))]
with pytest.raises(AttributeError) as exc_info:
font.exact_names = exact_names
assert str(exc_info.value) == "property 'exact_names' of 'NormalFontFace' object has no setter"


def test_weight_property():
font = NormalFontFace(0, [Name("test", Language.get("en"))], [], 400, False, False, FontType.TRUETYPE)
weight = 900
with pytest.raises(AttributeError) as exc_info:
font.weight = weight
assert str(exc_info.value) == "property 'weight' of 'NormalFontFace' object has no setter"


def test_is_italic_property():
font = NormalFontFace(0, [Name("test", Language.get("en"))], [], 400, False, False, FontType.TRUETYPE)
is_italic = True
with pytest.raises(AttributeError) as exc_info:
font.is_italic = is_italic
assert str(exc_info.value) == "property 'is_italic' of 'NormalFontFace' object has no setter"


def test_is_glyph_emboldened_property():
font = NormalFontFace(0, [Name("test", Language.get("en"))], [], 400, False, False, FontType.TRUETYPE)
is_glyph_emboldened = True
with pytest.raises(AttributeError) as exc_info:
font.is_glyph_emboldened = is_glyph_emboldened
assert str(exc_info.value) == "property 'is_glyph_emboldened' of 'NormalFontFace' object has no setter"


def test_font_type():
font = NormalFontFace(0, [Name("test", Language.get("en"))], [], 400, False, False, FontType.TRUETYPE)
font_type = FontType.OPENTYPE
with pytest.raises(AttributeError) as exc_info:
font.font_type = font_type
assert str(exc_info.value) == "property 'font_type' of 'NormalFontFace' object has no setter"


def test_link_face_to_a_font_file():
Expand Down
9 changes: 0 additions & 9 deletions tests/font/test_variable_font.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,29 +56,25 @@ def test__init__():
assert str(exc_info.value) == "The font does not contain an valid family prefix."



def test_font_index_property():
font = VariableFontFace(0, [Name("test", Language.get("en"))], [], [], 400, False, FontType.TRUETYPE, {})
font_index = 1
with pytest.raises(AttributeError) as exc_info:
font.font_index = font_index
assert str(exc_info.value) == "property 'font_index' of 'VariableFontFace' object has no setter"


def test_families_prefix_property():
font = VariableFontFace(0, [Name("test", Language.get("en"))], [], [], 400, False, FontType.TRUETYPE, {})
families_prefix = [Name("test", Language.get("en"))]
with pytest.raises(AttributeError) as exc_info:
font.families_prefix = families_prefix
assert str(exc_info.value) == "property 'families_prefix' of 'VariableFontFace' object has no setter"


def test_families_suffix_property():
font = VariableFontFace(0, [Name("test", Language.get("en"))], [], [], 400, False, FontType.TRUETYPE, {})
families_suffix = [Name("test", Language.get("en"))]
with pytest.raises(AttributeError) as exc_info:
font.families_suffix = families_suffix
assert str(exc_info.value) == "property 'families_suffix' of 'VariableFontFace' object has no setter"


def test_family_names_property():
Expand Down Expand Up @@ -106,7 +102,6 @@ def test_exact_names_suffix_property():
exact_names_suffix = [Name("test", Language.get("en"))]
with pytest.raises(AttributeError) as exc_info:
font.exact_names_suffix = exact_names_suffix
assert str(exc_info.value) == "property 'exact_names_suffix' of 'VariableFontFace' object has no setter"


def test_exact_names_property():
Expand Down Expand Up @@ -134,15 +129,13 @@ def test_weight_property():
weight = 900
with pytest.raises(AttributeError) as exc_info:
font.weight = weight
assert str(exc_info.value) == "property 'weight' of 'VariableFontFace' object has no setter"


def test_is_italic_property():
font = VariableFontFace(0, [Name("test", Language.get("en"))], [], [], 400, False, FontType.TRUETYPE, {})
is_italic = True
with pytest.raises(AttributeError) as exc_info:
font.is_italic = is_italic
assert str(exc_info.value) == "property 'is_italic' of 'VariableFontFace' object has no setter"


def test_is_glyph_emboldened_property():
Expand All @@ -163,15 +156,13 @@ def test_font_type_property():
font_type = FontType.OPENTYPE
with pytest.raises(AttributeError) as exc_info:
font.font_type = font_type
assert str(exc_info.value) == "property 'font_type' of 'VariableFontFace' object has no setter"


def test_named_instance_coordinates_property():
font = VariableFontFace(0, [Name("test", Language.get("en"))], [], [], 400, False, FontType.TRUETYPE, {})
named_instance_coordinates = {"wght": 800}
with pytest.raises(AttributeError) as exc_info:
font.font_type = named_instance_coordinates
assert str(exc_info.value) == "property 'font_type' of 'VariableFontFace' object has no setter"


def test_link_face_to_a_font_file():
Expand Down

0 comments on commit a29ffe8

Please sign in to comment.