summaryrefslogtreecommitdiff
path: root/tests/test_python.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_python.py')
-rw-r--r--tests/test_python.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/tests/test_python.py b/tests/test_python.py
index f5784cb1..6445022c 100644
--- a/tests/test_python.py
+++ b/tests/test_python.py
@@ -3,7 +3,7 @@
Python Tests
~~~~~~~~~~~~
- :copyright: Copyright 2006-2015 by the Pygments team, see AUTHORS.
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
@@ -111,3 +111,23 @@ 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.Float, u'1_000e1_000j'),
+ (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)))