diff options
Diffstat (limited to 'Lib/test/test_format.py')
-rw-r--r-- | Lib/test/test_format.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py index 015d68e..fc71e48 100644 --- a/Lib/test/test_format.py +++ b/Lib/test/test_format.py @@ -332,20 +332,29 @@ class FormatTest(unittest.TestCase): self.assertIs(text % (), text) self.assertIs(text.format(), text) - @support.cpython_only def test_precision(self): - from _testcapi import INT_MAX - f = 1.2 self.assertEqual(format(f, ".0f"), "1") self.assertEqual(format(f, ".3f"), "1.200") with self.assertRaises(ValueError) as cm: - format(f, ".%sf" % (INT_MAX + 1)) + format(f, ".%sf" % (sys.maxsize + 1)) c = complex(f) self.assertEqual(format(c, ".0f"), "1+0j") self.assertEqual(format(c, ".3f"), "1.200+0.000j") with self.assertRaises(ValueError) as cm: + format(c, ".%sf" % (sys.maxsize + 1)) + + @support.cpython_only + def test_precision_c_limits(self): + from _testcapi import INT_MAX + + f = 1.2 + with self.assertRaises(ValueError) as cm: + format(f, ".%sf" % (INT_MAX + 1)) + + c = complex(f) + with self.assertRaises(ValueError) as cm: format(c, ".%sf" % (INT_MAX + 1)) |