diff options
author | Georg Brandl <georg@python.org> | 2011-09-22 13:16:18 +0200 |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2011-09-22 13:16:18 +0200 |
commit | 8c68cf5c445e6629d6c123668a23829d683e9ecd (patch) | |
tree | bd79e1a6f5c43cf31418d93e9217faa3508c34c8 /tests/test_basic_api.py | |
parent | 3271b375f38b1baeda54eb4809ec9404c34b01d4 (diff) | |
parent | 12f4389a72507ea123dba144b2a48bfb4e73793b (diff) | |
download | pygments-8c68cf5c445e6629d6c123668a23829d683e9ecd.tar.gz |
Merged in dvarrazzo/pygments-postgres (pull request #19)
Diffstat (limited to 'tests/test_basic_api.py')
-rw-r--r-- | tests/test_basic_api.py | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py index 77c0aaea..02261d24 100644 --- a/tests/test_basic_api.py +++ b/tests/test_basic_api.py @@ -3,7 +3,7 @@ Pygments basic API tests ~~~~~~~~~~~~~~~~~~~~~~~~ - :copyright: Copyright 2006-2010 by the Pygments team, see AUTHORS. + :copyright: Copyright 2006-2011 by the Pygments team, see AUTHORS. :license: BSD, see LICENSE for details. """ @@ -42,6 +42,8 @@ def test_lexer_classes(): "%s: %s attribute wrong" % (cls, attr) result = cls.analyse_text("abc") assert isinstance(result, float) and 0.0 <= result <= 1.0 + result = cls.analyse_text(".abc") + assert isinstance(result, float) and 0.0 <= result <= 1.0 inst = cls(opt1="val1", opt2="val2") if issubclass(cls, RegexLexer): @@ -55,6 +57,9 @@ def test_lexer_classes(): assert 'root' in cls._tokens, \ '%s has no root state' % cls + if cls.name == 'XQuery': # XXX temporary + return + tokens = list(inst.get_tokens(test_content)) txt = "" for token in tokens: @@ -115,6 +120,15 @@ def test_get_lexers(): ]: yield verify, func, args + for cls, (_, lname, aliases, _, mimetypes) in lexers.LEXERS.iteritems(): + assert cls == lexers.find_lexer_class(lname).__name__ + + for alias in aliases: + assert cls == lexers.get_lexer_by_name(alias).__class__.__name__ + + for mimetype in mimetypes: + assert cls == lexers.get_lexer_for_mimetype(mimetype).__class__.__name__ + def test_formatter_public_api(): ts = list(lexers.PythonLexer().get_tokens("def f(): pass")) |