diff options
author | Georg Brandl <georg@python.org> | 2014-09-20 11:56:59 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-09-20 11:56:59 +0200 |
commit | b4e544bcfff8ad69d3aafb54b1060ebb53e71df6 (patch) | |
tree | 4cb5001dabc3a391f60fcccead4492a919185150 /tests | |
parent | 569a560c3875bdc589030413ed8b14d7c285670e (diff) | |
download | pygments-b4e544bcfff8ad69d3aafb54b1060ebb53e71df6.tar.gz |
make test with -v a bit easier on the eyes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_basic_api.py | 9 | ||||
-rw-r--r-- | tests/test_examplefiles.py | 17 |
2 files changed, 14 insertions, 12 deletions
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index 8998858c..e6b9b325 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -154,7 +154,8 @@ def test_formatter_public_api(): ts = list(lexers.PythonLexer().get_tokens("def f(): pass")) out = StringIO() - def verify(formatter, info): + def verify(formatter): + info = formatters.FORMATTERS[formatter.__name__] assert len(info) == 5 assert info[1], "missing formatter name" assert info[2], "missing formatter aliases" @@ -175,9 +176,9 @@ def test_formatter_public_api(): pass inst.format(ts, out) - for formatter, info in formatters.FORMATTERS.items(): - fmter = getattr(formatters, formatter) - yield verify, fmter, info + for name in formatters.FORMATTERS: + formatter = getattr(formatters, name) + yield verify, formatter def test_formatter_encodings(): diff --git a/tests/test_examplefiles.py b/tests/test_examplefiles.py index eabb0cf7..12f9d62f 100644 --- a/tests/test_examplefiles.py +++ b/tests/test_examplefiles.py @@ -22,20 +22,21 @@ STORE_OUTPUT = False STATS = {} +TESTDIR = os.path.dirname(__file__) + # generate methods def test_example_files(): global STATS STATS = {} - testdir = os.path.dirname(__file__) - outdir = os.path.join(testdir, 'examplefiles', 'output') + outdir = os.path.join(TESTDIR, 'examplefiles', 'output') if STORE_OUTPUT and not os.path.isdir(outdir): os.makedirs(outdir) - for fn in os.listdir(os.path.join(testdir, 'examplefiles')): + for fn in os.listdir(os.path.join(TESTDIR, 'examplefiles')): if fn.startswith('.') or fn.endswith('#'): continue - absfn = os.path.join(testdir, 'examplefiles', fn) + absfn = os.path.join(TESTDIR, 'examplefiles', fn) if not os.path.isfile(absfn): continue @@ -46,8 +47,6 @@ def test_example_files(): except UnicodeError: code = code.decode('latin1') - outfn = os.path.join(outdir, fn) - lx = None if '_' in fn: try: @@ -62,7 +61,7 @@ def test_example_files(): 'nor is of the form <lexer>_filename ' 'for overriding, thus no lexer found.' % fn) - yield check_lexer, lx, absfn, outfn + yield check_lexer, lx, fn N = 7 stats = list(STATS.items()) @@ -77,7 +76,8 @@ def test_example_files(): print('%-30s %6d chars %8.2f ms %7.3f ms/char' % ((fn,) + t)) -def check_lexer(lx, absfn, outfn): +def check_lexer(lx, fn): + absfn = os.path.join(TESTDIR, 'examplefiles', fn) fp = open(absfn, 'rb') try: text = fp.read() @@ -112,6 +112,7 @@ def check_lexer(lx, absfn, outfn): # check output against previous run if enabled if STORE_OUTPUT: # no previous output -- store it + outfn = os.path.join(TESTDIR, 'examplefiles', 'output', fn) if not os.path.isfile(outfn): fp = open(outfn, 'wb') try: |