summaryrefslogtreecommitdiff
path: root/tests/test_basic_api.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2019-05-06 16:18:56 +0200
committerGeorg Brandl <georg@python.org>2019-11-10 10:15:13 +0100
commita281ff8367a3a5f4cc17c9956e9273593558d336 (patch)
treeee145581327104377a6d079d2c3ec5c1e188bf7d /tests/test_basic_api.py
parenta41f232a0aa9f2b435e54a7e247c858a8f2d7fa8 (diff)
downloadpygments-git-a281ff8367a3a5f4cc17c9956e9273593558d336.tar.gz
Cleanup test modules, more pytest-like testing.
Diffstat (limited to 'tests/test_basic_api.py')
-rw-r--r--tests/test_basic_api.py11
1 files changed, 4 insertions, 7 deletions
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index 07b2f09c..5e7c443d 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -91,7 +91,7 @@ def test_lexer_options(cls):
def ensure(tokens, output):
concatenated = ''.join(token[1] for token in tokens)
assert concatenated == output, \
- '%s: %r != %r' % (lexer, concatenated, output)
+ '%s: %r != %r' % (cls, concatenated, output)
inst = cls(stripnl=False)
ensure(inst.get_tokens('a\nb'), 'a\nb\n')
@@ -111,18 +111,15 @@ def test_lexer_options(cls):
def test_get_lexers():
# test that the lexers functions work
- def verify(func, args):
- x = func(opt='val', *args)
- assert isinstance(x, lexers.PythonLexer)
- assert x.options["opt"] == "val"
-
for func, args in [(lexers.get_lexer_by_name, ("python",)),
(lexers.get_lexer_for_filename, ("test.py",)),
(lexers.get_lexer_for_mimetype, ("text/x-python",)),
(lexers.guess_lexer, ("#!/usr/bin/python -O\nprint",)),
(lexers.guess_lexer_for_filename, ("a.py", "<%= @foo %>"))
]:
- verify(func, args)
+ x = func(opt='val', *args)
+ assert isinstance(x, lexers.PythonLexer)
+ assert x.options["opt"] == "val"
for cls, (_, lname, aliases, _, mimetypes) in lexers.LEXERS.items():
assert cls == lexers.find_lexer_class(lname).__name__