summaryrefslogtreecommitdiff
path: root/tests/test_python.py
diff options
context:
space:
mode:
authorKevin Stone <kevinastone@gmail.com>2017-05-02 10:03:14 -0700
committerKevin Stone <kevinastone@gmail.com>2017-05-02 10:03:14 -0700
commitb28b24c5ffe0274a2ac45398766213e83bf6b2d7 (patch)
tree0a9fb7539a8d7f0eed8e79c8debd471bf1e07872 /tests/test_python.py
parent0db8e281af377923115b894703b2b8beb8f1e9d5 (diff)
downloadpygments-b28b24c5ffe0274a2ac45398766213e83bf6b2d7.tar.gz
Added pep 515 support to the python lexer
Fixes #1299
Diffstat (limited to 'tests/test_python.py')
-rw-r--r--tests/test_python.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/tests/test_python.py b/tests/test_python.py
index e99687a6..6ef8169d 100644
--- a/tests/test_python.py
+++ b/tests/test_python.py
@@ -111,3 +111,22 @@ class Python3Test(unittest.TestCase):
(Token.Text, u'\n'),
]
self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))
+
+ def test_pep_515(self):
+ """
+ Tests that the lexer can parse numeric literals with underscores
+ """
+ fragments = (
+ (Token.Literal.Number.Integer, u'1_000_000'),
+ (Token.Literal.Number.Float, u'1_000.000_001'),
+ (Token.Literal.Number.Hex, u'0xCAFE_F00D'),
+ (Token.Literal.Number.Bin, u'0b_0011_1111_0100_1110'),
+ (Token.Literal.Number.Oct, u'0o_777_123'),
+ )
+
+ for token, fragment in fragments:
+ tokens = [
+ (token, fragment),
+ (Token.Text, u'\n'),
+ ]
+ self.assertEqual(tokens, list(self.lexer.get_tokens(fragment)))