summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-02-07 13:15:37 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-02-07 13:15:37 (GMT)
commit5354a1fce0d43054ba43cb7fd15769b265e42fde (patch)
tree061ea507523ea78e9cf320fcffae29e373b5dc0f
parent8af24c111bd5f4383d46ebbadd554b1d2686331f (diff)
downloadcpython-5354a1fce0d43054ba43cb7fd15769b265e42fde.zip
cpython-5354a1fce0d43054ba43cb7fd15769b265e42fde.tar.gz
cpython-5354a1fce0d43054ba43cb7fd15769b265e42fde.tar.bz2
Merged revisions 78082,78086 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r78082 | mark.dickinson | 2010-02-07 13:01:56 +0000 (Sun, 07 Feb 2010) | 1 line Add missing global declarations for 'overflowok'; remove 'overflowrequired', which is no longer needed. ........ r78086 | mark.dickinson | 2010-02-07 13:09:52 +0000 (Sun, 07 Feb 2010) | 1 line Actually raise on failure, instead of doing nothing. ........
-rw-r--r--Lib/test/test_format.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index 054baf6..88eb61a 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -11,7 +11,6 @@ maxsize = support.MAX_Py_ssize_t
# test on unicode strings as well
overflowok = 1
-overflowrequired = 0
def testformat(formatstr, args, output=None, limit=None):
if verbose:
@@ -28,15 +27,9 @@ def testformat(formatstr, args, output=None, limit=None):
if verbose:
print('overflow (this is fine)')
else:
- if overflowrequired:
+ if output and limit is None and result != output:
if verbose:
print('no')
- print("overflow expected on %r %% %r" % (formatstr, args))
- elif output and limit is None and result != output:
- if verbose:
- print('no')
- #print("%r %% %r == %r != %r" %\
- # (formatstr, args, result, output))
raise AssertionError("%r %% %r == %r != %r" %
(formatstr, args, result, output))
# when 'limit' is specified, it determines how many characters
@@ -57,6 +50,8 @@ def testformat(formatstr, args, output=None, limit=None):
class FormatTest(unittest.TestCase):
def test_format(self):
+ global overflowok
+
testformat("%.1d", (1,), "1")
testformat("%.*d", (sys.maxsize,1)) # expect overflow
testformat("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
@@ -72,13 +67,14 @@ class FormatTest(unittest.TestCase):
testformat("%#.*g", (110, -1.e+100/3.))
# test some ridiculously large precision, expect overflow
testformat('%12.*f', (123456, 1.0))
+
# check for internal overflow validation on length of precision
- overflowrequired = 1
+ # these tests should no longer cause overflow in Python
+ # 2.7/3.1 and later.
testformat("%#.*g", (110, -1.e+100/3.))
testformat("%#.*G", (110, -1.e+100/3.))
testformat("%#.*f", (110, -1.e+100/3.))
testformat("%#.*F", (110, -1.e+100/3.))
- overflowrequired = 0
# Formatting of integers. Overflow is not ok
overflowok = 0
testformat("%x", 10, "a")