diff options
Diffstat (limited to 'Lib/test/test_fractions.py')
-rw-r--r-- | Lib/test/test_fractions.py | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/Lib/test/test_fractions.py b/Lib/test/test_fractions.py index 37de3ad380e..d1d2739856c 100644 --- a/Lib/test/test_fractions.py +++ b/Lib/test/test_fractions.py @@ -500,22 +500,23 @@ class FractionTest(unittest.TestCase): def test_limit_int(self): maxdigits = 5000 with adjust_int_max_str_digits(maxdigits): + msg = 'Exceeds the limit' val = '1' * maxdigits num = (10**maxdigits - 1)//9 self.assertEqual((num, 1), _components(F(val))) - self.assertRaises(ValueError, F, val + '1') + self.assertRaisesRegex(ValueError, msg, F, val + '1') self.assertEqual((num, 2), _components(F(val + '/2'))) - self.assertRaises(ValueError, F, val + '1/2') + self.assertRaisesRegex(ValueError, msg, F, val + '1/2') self.assertEqual((1, num), _components(F('1/' + val))) - self.assertRaises(ValueError, F, '1/1' + val) + self.assertRaisesRegex(ValueError, msg, F, '1/1' + val) self.assertEqual(((10**(maxdigits+1) - 1)//9, 10**maxdigits), _components(F('1.' + val))) - self.assertRaises(ValueError, F, '1.1' + val) + self.assertRaisesRegex(ValueError, msg, F, '1.1' + val) self.assertEqual((num, 10**maxdigits), _components(F('.' + val))) - self.assertRaises(ValueError, F, '.1' + val) - self.assertRaises(ValueError, F, '1.1e1' + val) + self.assertRaisesRegex(ValueError, msg, F, '.1' + val) + self.assertRaisesRegex(ValueError, msg, F, '1.1e1' + val) self.assertEqual((11, 10), _components(F('1.1e' + '0' * maxdigits))) - self.assertRaises(ValueError, F, '1.1e' + '0' * (maxdigits+1)) + self.assertRaisesRegex(ValueError, msg, F, '1.1e' + '0' * (maxdigits+1)) def testImmutable(self): r = F(7, 3) @@ -1517,6 +1518,8 @@ class FractionTest(unittest.TestCase): (F(51, 1000), '.1f', '0.1'), (F(149, 1000), '.1f', '0.1'), (F(151, 1000), '.1f', '0.2'), + (F(22, 7), '.02f', '3.14'), # issue gh-130662 + (F(22, 7), '005.02f', '03.14'), ] for fraction, spec, expected in testcases: with self.subTest(fraction=fraction, spec=spec): @@ -1615,12 +1618,6 @@ class FractionTest(unittest.TestCase): '=010%', '>00.2f', '>00f', - # Too many zeros - minimum width should not have leading zeros - '006f', - # Leading zeros in precision - '.010f', - '.02f', - '.000f', # Missing precision '.e', '.f', |