Mercurial > hgrepos > Python > libs > pygments-lexer-pseudocode2
comparison tests/test_algpseudo.py @ 288:298841bc4dee
Allow "normal" Pygments token names in "\ttX" ("Error", "Text.Whitespace", ...)
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Fri, 22 May 2026 12:32:38 +0200 |
| parents | 051c8877ee22 |
| children | 6fc7f9c1d89d |
comparison
equal
deleted
inserted
replaced
| 287:f506d752e801 | 288:298841bc4dee |
|---|---|
| 10 | 10 |
| 11 import pygments | 11 import pygments |
| 12 import pygments.lexers | 12 import pygments.lexers |
| 13 import pygments.formatters | 13 import pygments.formatters |
| 14 from pygments.token import Token | 14 from pygments.token import Token |
| 15 | |
| 16 from pygments_lexer_pseudocode2.utils import string_to_defined_tokentype | |
| 15 | 17 |
| 16 import _testhelper | 18 import _testhelper |
| 17 | 19 |
| 18 | 20 |
| 19 class TestSnippets(unittest.TestCase, _testhelper.TokenAssertHelper): | 21 class TestSnippets(unittest.TestCase, _testhelper.TokenAssertHelper): |
| 1241 latex_formatter, | 1243 latex_formatter, |
| 1242 outfile=None) | 1244 outfile=None) |
| 1243 self.assertTrue(highlighted.startswith(r"""\begin{Verbatim}""")) | 1245 self.assertTrue(highlighted.startswith(r"""\begin{Verbatim}""")) |
| 1244 | 1246 |
| 1245 | 1247 |
| 1248 class TokenBehaviour(unittest.TestCase): | |
| 1249 | |
| 1250 def test_string_to_defined_tokentype(self): | |
| 1251 t = string_to_defined_tokentype("Generic") | |
| 1252 self.assertIs(t, Token.Generic) | |
| 1253 | |
| 1254 def test_string_to_defined_tokentype_2(self): | |
| 1255 t = string_to_defined_tokentype("Generic.Error") | |
| 1256 self.assertIs(t, Token.Generic.Error) | |
| 1257 | |
| 1258 def test_string_to_defined_tokentype_empty(self): | |
| 1259 t = string_to_defined_tokentype("") | |
| 1260 self.assertIs(t, Token) | |
| 1261 | |
| 1262 def test_string_to_undefined_tokentype(self): | |
| 1263 self.assertIsNone(string_to_defined_tokentype("non-existing")) | |
| 1264 # twice to assert that it it not created by the call | |
| 1265 self.assertIsNone(string_to_defined_tokentype("non-existing")) | |
| 1266 | |
| 1267 def test_string_to_undefined_tokentype_2(self): | |
| 1268 self.assertIsNone(string_to_defined_tokentype("Generic.non-existing")) | |
| 1269 # twice to assert that it it not created by the call | |
| 1270 self.assertIsNone(string_to_defined_tokentype("Generic.non-existing")) | |
| 1271 | |
| 1272 def test_string_to_undefined_tokentype_3(self): | |
| 1273 self.assertIsNone(string_to_defined_tokentype("Not.Yet.Existing")) | |
| 1274 # twice to assert that it it not created by the call | |
| 1275 self.assertIsNone(string_to_defined_tokentype("Not.Yet.Existing")) | |
| 1276 | |
| 1277 def test_string_to_undefined_tokentype_4(self): | |
| 1278 self.assertIsNone(string_to_defined_tokentype("Generic..Error")) | |
| 1279 # twice to assert that it it not created by the call | |
| 1280 self.assertIsNone(string_to_defined_tokentype("Generic..Error")) | |
| 1281 | |
| 1282 | |
| 1246 if __name__ == "__main__": | 1283 if __name__ == "__main__": |
| 1247 unittest.main() | 1284 unittest.main() |
