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
commit4c0803e816c971f48691767da0755aab43edaa77 (patch)
treeb638b93b3d1cd49c39864334f1f580ccf4c92a74 /tests/test_python.py
parent1b966038502c0b386a6645d4b5125f623d0947bb (diff)
downloadpygments-git-4c0803e816c971f48691767da0755aab43edaa77.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)))