summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2016-11-01 11:17:40 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2016-11-01 11:18:46 +0200
commitef965b545bdf765ea0dff1624a3258b2f1ba482d (patch)
treecbebb8e80f6239b70de7777b805e29bfac77b07d
parent3b95628c7aa2b2c5ae173d0982edec0749760873 (diff)
downloadastroid-git-ef965b545bdf765ea0dff1624a3258b2f1ba482d.tar.gz
Add test for underscores in numeral literal (Python 3.6)
-rw-r--r--astroid/tests/unittest_python3.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/astroid/tests/unittest_python3.py b/astroid/tests/unittest_python3.py
index a9ef11e0..d49fd99e 100644
--- a/astroid/tests/unittest_python3.py
+++ b/astroid/tests/unittest_python3.py
@@ -247,6 +247,25 @@ class Python3TC(unittest.TestCase):
for name, arg in zip(('cls', 'class_or_tuple'), ast.args.positional_only):
self.assertEqual(arg.name, name)
+ @require_version('3.6')
+ def test_format_string(self):
+ code = "f'{greetings} {person}'"
+ node = extract_node(code)
+ self.assertEqual(node.as_string(), code)
+
+ @require_version('3.6')
+ def test_underscores_in_numeral_literal(self):
+ pairs = [
+ ('10_1000', 101000),
+ ('10_000_000', 10000000),
+ ('0x_FF_FF', 65535),
+ ]
+ for value, expected in pairs:
+ node = extract_node(value)
+ inferred = next(node.infer())
+ self.assertIsInstance(inferred, nodes.Const)
+ self.assertEqual(inferred.value, expected)
+
if __name__ == '__main__':
unittest.main()