diff options
author | Eric Smith <eric@trueblade.com> | 2007-08-30 22:23:08 (GMT) |
---|---|---|
committer | Eric Smith <eric@trueblade.com> | 2007-08-30 22:23:08 (GMT) |
commit | 185e30cdf330b0c687a7afaf26b1eef761ff12ca (patch) | |
tree | 207ffc5193da7731b951d1e7e6819940517551f4 /Lib/test/test_long.py | |
parent | bc3b345f8284620bba07e9c2ec4cd64553f2b983 (diff) | |
download | cpython-185e30cdf330b0c687a7afaf26b1eef761ff12ca.zip cpython-185e30cdf330b0c687a7afaf26b1eef761ff12ca.tar.gz cpython-185e30cdf330b0c687a7afaf26b1eef761ff12ca.tar.bz2 |
Added format tests.
Fixed bug in alignment of negative numbers.
Whitespace normalization.
Diffstat (limited to 'Lib/test/test_long.py')
-rw-r--r-- | Lib/test/test_long.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/Lib/test/test_long.py b/Lib/test/test_long.py index 4e15340..4ba825a 100644 --- a/Lib/test/test_long.py +++ b/Lib/test/test_long.py @@ -497,13 +497,25 @@ class LongTest(unittest.TestCase): self.assertEqual(format(123456789, 'd'), '123456789') self.assertEqual(format(123456789, 'd'), '123456789') + # sign and aligning are interdependent + self.assertEqual(format(1, "-"), '1') + self.assertEqual(format(-1, "-"), '-1') + self.assertEqual(format(1, "-3"), ' 1') + self.assertEqual(format(-1, "-3"), ' -1') + self.assertEqual(format(1, "+3"), ' +1') + self.assertEqual(format(-1, "+3"), ' -1') + self.assertEqual(format(1, " 3"), ' 1') + self.assertEqual(format(-1, " 3"), ' -1') + self.assertEqual(format(1, " "), ' 1') + self.assertEqual(format(-1, " "), '-1') + # hex self.assertEqual(format(3, "x"), "3") self.assertEqual(format(3, "X"), "3") self.assertEqual(format(1234, "x"), "4d2") self.assertEqual(format(-1234, "x"), "-4d2") self.assertEqual(format(1234, "8x"), " 4d2") -# XXX fix self.assertEqual(format(-1234, "8x"), " -4d2") + self.assertEqual(format(-1234, "8x"), " -4d2") self.assertEqual(format(1234, "x"), "4d2") self.assertEqual(format(-1234, "x"), "-4d2") self.assertEqual(format(-3, "x"), "-3") @@ -530,7 +542,6 @@ class LongTest(unittest.TestCase): # make sure these are errors self.assertRaises(ValueError, format, 3, "1.3") # precision disallowed - return self.assertRaises(ValueError, format, 3, "+c") # sign not allowed # with 'c' self.assertRaises(ValueError, format, 3, "R") # bogus format type |