summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_unicode.py
diff options
context:
space:
mode:
authorMark Dickinson <mdickinson@enthought.com>2012-10-28 10:22:22 (GMT)
committerMark Dickinson <mdickinson@enthought.com>2012-10-28 10:22:22 (GMT)
commit2a83f16e5e06f3ba27e3cc0d7819a16c40f9a9cb (patch)
tree8a2aa9faeb3e10fbe7bf66e919f8bc469181a71b /Lib/test/test_unicode.py
parent5b9561d1f1548787e518934aea02fad8a0391ab5 (diff)
parentfb90c0934c22041cad1fc4019c9853205befc967 (diff)
downloadcpython-2a83f16e5e06f3ba27e3cc0d7819a16c40f9a9cb.zip
cpython-2a83f16e5e06f3ba27e3cc0d7819a16c40f9a9cb.tar.gz
cpython-2a83f16e5e06f3ba27e3cc0d7819a16c40f9a9cb.tar.bz2
Issue #14700: merge tests from 3.2.
Diffstat (limited to 'Lib/test/test_unicode.py')
-rw-r--r--Lib/test/test_unicode.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/Lib/test/test_unicode.py b/Lib/test/test_unicode.py
index b13a90a..46c98bd 100644
--- a/Lib/test/test_unicode.py
+++ b/Lib/test/test_unicode.py
@@ -981,6 +981,21 @@ class UnicodeTest(string_tests.CommonTest,
self.assertRaises(ValueError, '{}'.format_map, 'a')
self.assertRaises(ValueError, '{a} {}'.format_map, {"a" : 2, "b" : 1})
+ def test_format_huge_precision(self):
+ format_string = ".{}f".format(sys.maxsize + 1)
+ with self.assertRaises(ValueError):
+ result = format(2.34, format_string)
+
+ def test_format_huge_width(self):
+ format_string = "{}f".format(sys.maxsize + 1)
+ with self.assertRaises(ValueError):
+ result = format(2.34, format_string)
+
+ def test_format_huge_item_number(self):
+ format_string = "{{{}:.6f}}".format(sys.maxsize + 1)
+ with self.assertRaises(ValueError):
+ result = format_string.format(2.34)
+
def test_format_auto_numbering(self):
class C:
def __init__(self, x=100):
@@ -1069,6 +1084,18 @@ class UnicodeTest(string_tests.CommonTest,
self.assertEqual('%.1s' % "a\xe9\u20ac", 'a')
self.assertEqual('%.2s' % "a\xe9\u20ac", 'a\xe9')
+ @support.cpython_only
+ def test_formatting_huge_precision(self):
+ from _testcapi import INT_MAX
+ format_string = "%.{}f".format(INT_MAX + 1)
+ with self.assertRaises(ValueError):
+ result = format_string % 2.34
+
+ def test_formatting_huge_width(self):
+ format_string = "%{}f".format(sys.maxsize + 1)
+ with self.assertRaises(ValueError):
+ result = format_string % 2.34
+
def test_startswith_endswith_errors(self):
for meth in ('foo'.startswith, 'foo'.endswith):
with self.assertRaises(TypeError) as cm: