Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison tests/test_algpseudo.py @ 66:9ba1584d4b4a
Also add a test that completely highlights a document with Pygments
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Tue, 28 Apr 2026 15:02:15 +0200 |
| parents | 05c53e431c88 |
| children | b3dd247b27a5 |
comparison
equal
deleted
inserted
replaced
| 65:3f4223a79d2b | 66:9ba1584d4b4a |
|---|---|
| 8 | 8 |
| 9 import unittest | 9 import unittest |
| 10 | 10 |
| 11 import pygments | 11 import pygments |
| 12 import pygments.lexers | 12 import pygments.lexers |
| 13 import pygments.formatters | |
| 13 | 14 |
| 14 import _testhelper | 15 import _testhelper |
| 15 | 16 |
| 16 | 17 |
| 17 class TestSnippets(unittest.TestCase, _testhelper.TokenAssertHelper): | 18 class TestSnippets(unittest.TestCase, _testhelper.TokenAssertHelper): |
| 279 """\\remArk the remark 1 | 280 """\\remArk the remark 1 |
| 280 \\Rem the remark 2 | 281 \\Rem the remark 2 |
| 281 """, self.lexer)) | 282 """, self.lexer)) |
| 282 | 283 |
| 283 | 284 |
| 285 class PygmentizeCompletely(unittest.TestCase): | |
| 286 | |
| 287 def setUp(self): | |
| 288 self.lexer = pygments.lexers.load_lexer_from_file( | |
| 289 ALGLEXERFILENAME, ALGLEXERCLASS) | |
| 290 | |
| 291 def test_pygmentize_html(self): | |
| 292 html_formatter = pygments.formatters.get_formatter_by_name("html") | |
| 293 highlighted = pygments.highlight( | |
| 294 '"""FOO"""', | |
| 295 self.lexer, | |
| 296 html_formatter, | |
| 297 outfile=None) | |
| 298 self.assertTrue(highlighted.startswith("""<div class="highlight">""")) | |
| 299 | |
| 300 def test_pygmentize_latex(self): | |
| 301 latex_formatter = pygments.formatters.get_formatter_by_name("latex") | |
| 302 highlighted = pygments.highlight( | |
| 303 '"""FOO"""', | |
| 304 self.lexer, | |
| 305 latex_formatter, | |
| 306 outfile=None) | |
| 307 self.assertTrue(highlighted.startswith(r"""\begin{Verbatim}""")) | |
| 308 | |
| 309 | |
| 284 if __name__ == "__main__": | 310 if __name__ == "__main__": |
| 285 unittest.main() | 311 unittest.main() |
