summaryrefslogtreecommitdiff
path: root/tests/test_basic_api.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2011-06-19 09:45:13 +0200
committerGeorg Brandl <georg@python.org>2011-06-19 09:45:13 +0200
commita275a0c40bc4dcd48f52e04e056d03cecb73e973 (patch)
tree142f5c6af5cb5348bc19010cdef29216bbc748a1 /tests/test_basic_api.py
parent8e50a30370b1ad58d8ec308d5ee7d4e7d153bc4a (diff)
parent0466a590eaf5face40a52d2ea245dc3f061723ef (diff)
downloadpygments-a275a0c40bc4dcd48f52e04e056d03cecb73e973.tar.gz
Merge with https://bitbucket.org/dvarrazzo/pygments-postgres
Diffstat (limited to 'tests/test_basic_api.py')
-rw-r--r--tests/test_basic_api.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/test_basic_api.py b/tests/test_basic_api.py
index 77c0aaea..794e124d 100644
--- a/tests/test_basic_api.py
+++ b/tests/test_basic_api.py
@@ -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"))