summaryrefslogtreecommitdiff
path: root/tests/test_python.py
diff options
context:
space:
mode:
authorJessie Wincek <jbwincek@gmail.com>2016-06-02 10:47:17 -0700
committerJessie Wincek <jbwincek@gmail.com>2016-06-02 10:47:17 -0700
commit89a4adc825f44aa4b32f559e4b540d44572cb06a (patch)
treeaf06ebc969cd26e387c4d192fd73baf9d829e618 /tests/test_python.py
parent7654e964ef10b3a48d4d7d9452b8492ab29ae218 (diff)
downloadpygments-89a4adc825f44aa4b32f559e4b540d44572cb06a.tar.gz
Added Python cls builtin word token recognition
Diffstat (limited to 'tests/test_python.py')
-rw-r--r--tests/test_python.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/test_python.py b/tests/test_python.py
new file mode 100644
index 00000000..21c69605
--- /dev/null
+++ b/tests/test_python.py
@@ -0,0 +1,46 @@
+# -*- coding: utf-8 -*-
+"""
+ Python Tests
+ ~~~~~~~~~
+
+ :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :license: BSD, see LICENSE for details.
+"""
+
+import unittest
+
+from pygments.lexers import PythonLexer
+from pygments.token import Token
+
+
+class PythonTest(unittest.TestCase):
+ def setUp(self):
+ self.lexer = PythonLexer()
+
+ def testNeedsName(self):
+ fragment = 'class TestClass():\n @classmethod\n def hello(cls):\n pass\n'
+ tokens = [
+ (Token.Keyword, 'class'),
+ (Token.Text, ' '),
+ (Token.Name.Class, 'TestClass'),
+ (Token.Punctuation, '('),
+ (Token.Punctuation, ')'),
+ (Token.Punctuation, ':'),
+ (Token.Text, '\n'),
+ (Token.Text, ' '),
+ (Token.Name.Decorator, '@classmethod'),
+ (Token.Text, '\n'),
+ (Token.Text, ' '),
+ (Token.Keyword, 'def'),
+ (Token.Text, ' '),
+ (Token.Name.Function, 'hello'),
+ (Token.Punctuation, '('),
+ (Token.Name.Builtin.Pseudo, 'cls'),
+ (Token.Punctuation, ')'),
+ (Token.Punctuation, ':'),
+ (Token.Text, '\n'),
+ (Token.Text, ' '),
+ (Token.Keyword, 'pass'),
+ (Token.Text, '\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))