summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-02-23 12:53:52 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-02-23 12:53:52 (GMT)
commit8ee9187a163b5c2735072096baf61affaa935063 (patch)
treed8487cfbc1108112d1daae487b6e7b99615d7de5
parentb8708a298e104be12ac6532dafecd81890aacd61 (diff)
downloadcpython-8ee9187a163b5c2735072096baf61affaa935063.zip
cpython-8ee9187a163b5c2735072096baf61affaa935063.tar.gz
cpython-8ee9187a163b5c2735072096baf61affaa935063.tar.bz2
Make global variable overflowok into a keyword argument; this fixes a failure when running ./python -m test.regrtest -R 3:2: test_format
-rw-r--r--Lib/test/test_format.py32
1 files changed, 16 insertions, 16 deletions
diff --git a/Lib/test/test_format.py b/Lib/test/test_format.py
index cb43624..11c0998 100644
--- a/Lib/test/test_format.py
+++ b/Lib/test/test_format.py
@@ -10,12 +10,7 @@ maxsize = test_support.MAX_Py_ssize_t
# they crash python)
# test on unicode strings as well
-overflowok = 1
-
-
-def testformat(formatstr, args, output=None, limit=None):
- global overflowok
-
+def testformat(formatstr, args, output=None, limit=None, overflowok=False):
if verbose:
if output:
print "%s %% %s =? %s ..." %\
@@ -51,21 +46,27 @@ def testformat(formatstr, args, output=None, limit=None):
print 'yes'
-def testboth(formatstr, *args):
- testformat(formatstr, *args)
+def testboth(formatstr, *args, **kwargs):
+ testformat(formatstr, *args, **kwargs)
if have_unicode:
- testformat(unicode(formatstr), *args)
+ testformat(unicode(formatstr), *args, **kwargs)
class FormatTest(unittest.TestCase):
def test_format(self):
- global overflowok
-
testboth("%.1d", (1,), "1")
- testboth("%.*d", (sys.maxint,1)) # expect overflow
- testboth("%.100d", (1,), '0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
- testboth("%#.117x", (1,), '0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
- testboth("%#.118x", (1,), '0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001')
+ testboth("%.*d", (sys.maxint,1), overflowok = True) # expect overflow
+ testboth("%.100d", (1,), '00000000000000000000000000000000000000'
+ '000000000000000000000000000000000000000000000000000000'
+ '00000001', overflowok = True)
+ testboth("%#.117x", (1,), '0x00000000000000000000000000000000000'
+ '000000000000000000000000000000000000000000000000000000'
+ '0000000000000000000000000001',
+ overflowok = True)
+ testboth("%#.118x", (1,), '0x00000000000000000000000000000000000'
+ '000000000000000000000000000000000000000000000000000000'
+ '00000000000000000000000000001',
+ overflowok = True)
testboth("%f", (1.0,), "1.000000")
# these are trying to test the limits of the internal magic-number-length
@@ -87,7 +88,6 @@ class FormatTest(unittest.TestCase):
testboth("%#.*F", (110, -1.e+100/3.))
# Formatting of long integers. Overflow is not ok
- overflowok = 0
testboth("%x", 10L, "a")
testboth("%x", 100000000000L, "174876e800")
testboth("%o", 10L, "12")