mirror of
https://github.com/python/cpython.git
synced 2025-07-12 13:55:34 +00:00
[3.11] gh-109546: Add more tests for formatting floats (GH-109548) (#109685)
gh-109546: Add more tests for formatting floats (GH-109548)
(cherry picked from commit beb5ec5817
)
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
This commit is contained in:
parent
ca8da713d5
commit
84d8fdb266
1 changed files with 7 additions and 2 deletions
|
@ -734,8 +734,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')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue