diff options
| author | Eric Smith <eric@trueblade.com> | 2009-04-03 14:45:06 +0000 |
|---|---|---|
| committer | Eric Smith <eric@trueblade.com> | 2009-04-03 14:45:06 +0000 |
| commit | a3b1ac8dca5afa01d9d542e125052014a9af56eb (patch) | |
| tree | b48929a3d3460d116182f81e7fb80dab5548211f /Lib | |
| parent | f8c8b6d3ea995d9ddce9470fe6fd2a9c956a5d5d (diff) | |
| download | cpython-git-a3b1ac8dca5afa01d9d542e125052014a9af56eb.tar.gz | |
Added ',' thousands grouping to int.__format__. See PEP 378.
This is incomplete, but I want to get some version into the next alpha. I am still working on:
Documentation.
More tests.
Implement for floats.
In addition, there's an existing bug with 'n' formatting that carries forward to thousands grouping (issue 5515).
Diffstat (limited to 'Lib')
| -rw-r--r-- | Lib/test/test_types.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_types.py b/Lib/test/test_types.py index c200e07b2a..0d4d1b3edc 100644 --- a/Lib/test/test_types.py +++ b/Lib/test/test_types.py @@ -338,6 +338,15 @@ class TypesTests(unittest.TestCase): test(123456, "#012X", '0X000001E240') test(-123456, "#012X", '-0X00001E240') + test(123, ',', '123') + test(-123, ',', '-123') + test(1234, ',', '1,234') + test(-1234, ',', '-1,234') + test(123456, ',', '123,456') + test(-123456, ',', '-123,456') + test(1234567, ',', '1,234,567') + test(-1234567, ',', '-1,234,567') + # make sure these are errors # precision disallowed @@ -347,6 +356,8 @@ class TypesTests(unittest.TestCase): # format spec must be string self.assertRaises(TypeError, 3 .__format__, None) self.assertRaises(TypeError, 3 .__format__, 0) + # can't have ',' with 'n' + self.assertRaises(ValueError, 3 .__format__, ",n") # ensure that only int and float type specifiers work for format_spec in ([chr(x) for x in range(ord('a'), ord('z')+1)] + |
