diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-09-19 05:09:11 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-19 05:09:11 (GMT) |
commit | beb5ec5817b645562ebbdd59f25683a93061c32c (patch) | |
tree | 3a1ba7341fb3dc14bd07b7afb4729287b71aaed8 /Lib/test/test_float.py | |
parent | c829975428253568d47ebfc3104fa7386b5e0b58 (diff) | |
download | cpython-beb5ec5817b645562ebbdd59f25683a93061c32c.zip cpython-beb5ec5817b645562ebbdd59f25683a93061c32c.tar.gz cpython-beb5ec5817b645562ebbdd59f25683a93061c32c.tar.bz2 |
gh-109546: Add more tests for formatting floats and fractions (GH-109548)
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r-- | Lib/test/test_float.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index c4ee1e0..84270ce 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -733,8 +733,13 @@ class FormatTestCase(unittest.TestCase): lhs, rhs = map(str.strip, line.split('->')) fmt, arg = lhs.split() - self.assertEqual(fmt % float(arg), rhs) - self.assertEqual(fmt % -float(arg), '-' + rhs) + f = float(arg) + self.assertEqual(fmt % f, rhs) + self.assertEqual(fmt % -f, '-' + rhs) + if fmt != '%r': + fmt2 = fmt[1:] + self.assertEqual(format(f, fmt2), rhs) + self.assertEqual(format(-f, fmt2), '-' + rhs) def test_issue5864(self): self.assertEqual(format(123.456, '.4'), '123.5') |