add a test for detecting python console sessions

This commit is contained in:
Benjamin Peterson
2009-01-01 10:33:41 -06:00
parent 3fd31a2628
commit bb6b7d9b31

View File

@@ -28,6 +28,11 @@ class MyLexer(RegexLexer):
],
}
class ComplainOnUnhighlighted(PygmentsBridge):
def unhighlighted(self, source):
raise AssertionError("should highlight %r" % source)
class MyFormatter(HtmlFormatter):
def format(self, tokensource, outfile):
outfile.write('test')
@@ -41,6 +46,18 @@ def test_add_lexer(app):
ret = bridge.highlight_block('ab', 'test')
assert '<span class="n">a</span>b' in ret
def test_detect_interactive():
bridge = ComplainOnUnhighlighted('html')
blocks = [
"""
>>> testing()
True
""",
]
for block in blocks:
ret = bridge.highlight_block(block.lstrip(), 'python')
assert ret.startswith("<div class=\"highlight\">")
def test_set_formatter():
PygmentsBridge.html_formatter = MyFormatter
try: