8000 Issue #14700: merge tests from 3.3. · python/cpython@61254b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 61254b9

Browse files
committed
Issue #14700: merge tests from 3.3.
2 parents 7fe16b3 + 2a83f16 commit 61254b9

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

Lib/test/test_unicode.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -981,6 +981,21 @@ def __format__(self, spec):
981981
self.assertRaises(ValueError, '{}'.format_map, 'a')
982982
self.assertRaises(ValueError, '{a} {}'.format_map, {"a" : 2, "b" : 1})
983983

984+
def test_format_huge_precision(self):
985+
format_string = ".{}f".format(sys.maxsize + 1)
986+
with self.assertRaises(ValueError):
987+
result = format(2.34, format_string)
988+
989+
def test_format_huge_width(self):
990+
format_string = "{}f".format(sys.maxsize + 1)
991+
with self.assertRaises(ValueError):
992+
result = format(2.34, format_string)
993+
994+
def test_format_huge_item_number(self):
995+
format_string = "{{{}:.6f}}".format(sys.maxsize + 1)
996+
with self.assertRaises(ValueError):
997+
result = format_string.format(2.34)
998+
984999
def test_format_auto_numbering(self):
9851000
class C:
9861001
def __init__(self, x=100):
@@ -1069,6 +1084,18 @@ def __str__(self):
10691084
self.assertEqual('%.1s' % "a\xe9\u20ac", 'a')
10701085
self.assertEqual('%.2s' % "a\xe9\u20ac", 'a\xe9')
10711086

1087+
@support.cpython_only
1088+
def test_formatting_huge_precision(self):
1089+
from _testcapi import INT_MAX
1090+
format_string = "%.{}f".format(INT_MAX + 1)
1091+
with self.assertRaises(ValueError):
1092+
result = format_string % 2.34
1093+
1094+
def test_formatting_huge_width(self):
1095+
format_string = "%{}f".format(sys.maxsize + 1)
1096+
with self.assertRaises(ValueError):
1097+
result = format_string % 2.34
1098+
10721099
def test_startswith_endswith_errors(self):
10731100
for meth in ('foo'.startswith, 'foo'.endswith):
10741101
with self.assertRaises(TypeError) as cm:

0 commit comments

Comments
 (0)
0