diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-08-01 10:41:49 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-08-01 10:41:49 (GMT) |
commit | 5b65df7ce200fd4320fe5db1a307ee438de7a5ee (patch) | |
tree | 5c1e679831cf9052232040d6252955b2458fd85d /Lib/test/test_complex.py | |
parent | 8708e385979ca6978da681ff6a27888facc41ba4 (diff) | |
download | cpython-5b65df7ce200fd4320fe5db1a307ee438de7a5ee.zip cpython-5b65df7ce200fd4320fe5db1a307ee438de7a5ee.tar.gz cpython-5b65df7ce200fd4320fe5db1a307ee438de7a5ee.tar.bz2 |
Issue #9416: Fix some issues with complex formatting where the
output with no type specifier failed to match the str output:
- format(complex(-0.0, 2.0), '-') omitted the real part from the output,
- format(complex(0.0, 2.0), '-') included a sign and parentheses.
Diffstat (limited to 'Lib/test/test_complex.py')
-rw-r--r-- | Lib/test/test_complex.py | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Lib/test/test_complex.py b/Lib/test/test_complex.py index cecf38f..1564e89 100644 --- a/Lib/test/test_complex.py +++ b/Lib/test/test_complex.py @@ -506,6 +506,16 @@ class ComplexTest(unittest.TestCase): self.assertEqual(format(z, '-'), str(z)) self.assertEqual(format(z, '<'), str(z)) self.assertEqual(format(z, '10'), str(z)) + z = complex(0.0, 3.0) + self.assertEqual(format(z, ''), str(z)) + self.assertEqual(format(z, '-'), str(z)) + self.assertEqual(format(z, '<'), str(z)) + self.assertEqual(format(z, '2'), str(z)) + z = complex(-0.0, 2.0) + self.assertEqual(format(z, ''), str(z)) + self.assertEqual(format(z, '-'), str(z)) + self.assertEqual(format(z, '<'), str(z)) + self.assertEqual(format(z, '3'), str(z)) self.assertEqual(format(1+3j, 'g'), '1+3j') self.assertEqual(format(3j, 'g'), '0+3j') |