[dummy testrunner] Decorators to register stuff; minor changes.
#!/usr/bin/env python
-# -*- coding: <encoding name> -*-
+# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals
-import types
-from collections import OrderedDict, Counter
-from itertools import chain
-import sys
-import traceback
-
from fontbakery.testrunner import (
INFO
, WARN
@@ -32,21 +26,27 @@ from fontbakery.test import condition, test
conditions={}
def registerCondition(condition):
conditions[condition.name] = condition
+ return condition
+
tests=[]
-registerTest = tests.append
+def registerTest(test):
+ tests.append(test)
+ return test
+@registerCondition
@condition
def fontNameNumber(font):
return int(font.split('_')[1])
registerCondition(fontNameNumber)
+@registerCondition
@condition
def isOddFontName(fontNameNumber):
#raise Exception('Just to see how much we can extract from this')
return fontNameNumber % 2 == 1
registerCondition(isOddFontName)
-
+@registerTest
@test(
id='com.google.fonts/1'
, conditions=['isOddFontName']
@@ -54,8 +54,8 @@ registerCondition(isOddFontName)
)
def oddNameBiggerThanOne(fontNameNumber):
return PASS if fontNameNumber > 1 else FAIL, fontNameNumber
-registerTest(oddNameBiggerThanOne)
+@registerTest
@test(
id='com.google.fonts/2'
, conditions=['not isOddFontName']
@@ -63,8 +63,8 @@ registerTest(oddNameBiggerThanOne)
)
def evenNameBiggerThanTwo(fontNameNumber):
return PASS if fontNameNumber > 2 else FAIL, fontNameNumber
-registerTest(evenNameBiggerThanTwo)
+@registerTest
@test(
id='com.google.fonts/3'
, description='Fontname starts with "font_".'
@@ -76,8 +76,7 @@ def fontNameStartsWithFont_(font):
yield PASS, 'Char at index {} is "{}".'.format(i, test[i])
else:
yield FAIL, 'Char at index {} is not "{}" in "{}".'.format(i, test[i], font)
- raise Exception('Just to see how much we can extract from this')
-registerTest(fontNameStartsWithFont_)
+ 1/0
testsections=[Section('Default', tests), Section('Special', tests)] # order=['*test']
@@ -92,7 +91,7 @@ fonts = ['font_1', 'font_2', 'font_3', 'font_4']
if __name__ == '__main__':
runner = TestRunner(googleSpec, {'fonts': fonts})
- tr = TerminalReporter()
- distribute_generator(runner.run(), [tr.receive_sync])
-
+ tr = TerminalReporter(runner=runner, is_async=False, print_progress=True
+ , collect_results_by='font')
+ distribute_generator(runner.run(), [tr.receive])
