pytest: test/020
(issue
@@ -18,9 +18,7 @@ test_statuses = (ERROR, FAIL, SKIP, PASS, WARN, INFO, DEBUG)
from fontTools.ttLib import TTFont
-@pytest.fixture
-def mada_ttFonts():
- paths = [
+mada_fonts = [
"data/test/mada/Mada-Black.ttf",
"data/test/mada/Mada-ExtraLight.ttf",
"data/test/mada/Mada-Medium.ttf",
@@ -29,12 +27,12 @@ def mada_ttFonts():
"data/test/mada/Mada-Light.ttf",
"data/test/mada/Mada-Regular.ttf",
]
- return [TTFont(path) for path in paths]
-
@pytest.fixture
-def cabin_ttFonts():
- paths = [
+def mada_ttFonts():
+ return [TTFont(path) for path in mada_fonts]
+
+cabin_fonts = [
"data/test/cabin/Cabin-BoldItalic.ttf",
"data/test/cabin/Cabin-Bold.ttf",
"data/test/cabin/Cabin-Italic.ttf",
@@ -44,7 +42,10 @@ def cabin_ttFonts():
"data/test/cabin/Cabin-SemiBoldItalic.ttf",
"data/test/cabin/Cabin-SemiBold.ttf"
]
- return [TTFont(path) for path in paths]
+
+@pytest.fixture
+def cabin_ttFonts():
+ return [TTFont(path) for path in cabin_fonts]
@pytest.fixture
@@ -542,6 +543,23 @@ def test_id_019():
assert status == PASS
+def test_id_020():
+ """ Checking OS/2 usWeightClass. """
+ from fontbakery.specifications.googlefonts import (check_OS2_usWeightClass,
+ style)
+ print('Test FAIL with a bad font...')
+ # Our reference Mada Regular is know to be bad here.
+ font = "data/test/mada/Mada-Regular.ttf"
+ status, message = list(check_OS2_usWeightClass(TTFont(font), style(font)))[-1]
+ assert status == FAIL
+
+ print('Test PASS with a good font...')
+ # All fonts in our reference Cabin family are know to be good here.
+ for font in cabin_fonts:
+ status, message = list(check_OS2_usWeightClass(TTFont(font), style(font)))[-1]
+ assert status == PASS
+
+
def test_id_029(mada_ttFonts):
""" Check copyright namerecords match license file. """
from fontbakery.specifications.googlefonts import \
