diff options
author | Georg Brandl <georg@python.org> | 2014-11-11 18:38:10 +0100 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2014-11-11 18:38:10 +0100 |
commit | de76526dbd90f0ff8c511de9cd24a6887e3bf90d (patch) | |
tree | 3678ad0bbe4b59b58b97c7706af4754267752723 /tests/test_basic_api.py | |
parent | cbe1e3e5132dceeb96b57195579567d49928c00e (diff) | |
download | pygments-de76526dbd90f0ff8c511de9cd24a6887e3bf90d.tar.gz |
Fix and test the "lex(class)" and "format(class)" handlers.
Diffstat (limited to 'tests/test_basic_api.py')
-rw-r--r-- | tests/test_basic_api.py | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index 7485df1a..84dd49bb 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -12,7 +12,7 @@ from __future__ import print_function import random import unittest -from pygments import lexers, formatters, filters, format +from pygments import lexers, formatters, lex, format from pygments.token import _TokenType, Text from pygments.lexer import RegexLexer from pygments.formatters.img import FontNotFound @@ -254,6 +254,23 @@ def test_styles(): HtmlFormatter(style="pastie") +def test_bare_class_handler(): + from pygments.formatters import HtmlFormatter + from pygments.lexers import PythonLexer + try: + lex('test\n', PythonLexer) + except TypeError as e: + assert 'lex() argument must be a lexer instance' in str(e) + else: + assert False, 'nothing raised' + try: + format([], HtmlFormatter) + except TypeError as e: + assert 'format() argument must be a formatter instance' in str(e) + else: + assert False, 'nothing raised' + + class FiltersTest(unittest.TestCase): def test_basic(self): |