2008-05-20 18:35:26 -03:00
|
|
|
from test.support import verbose, TestFailed
|
2012-02-23 19:37:51 -04:00
|
|
|
import locale
|
2001-02-09 07:46:37 -04:00
|
|
|
import sys
|
2008-05-20 18:35:26 -03:00
|
|
|
import test.support as support
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
import unittest
|
|
|
|
|
2008-05-20 18:35:26 -03:00
|
|
|
maxsize = support.MAX_Py_ssize_t
|
2000-06-30 07:26:29 -03:00
|
|
|
|
|
|
|
# test string formatting operator (I am not sure if this is being tested
|
|
|
|
# elsewhere but, surely, some of the given cases are *not* tested because
|
|
|
|
# they crash python)
|
2015-01-24 00:05:18 -04:00
|
|
|
# test on bytes object as well
|
2000-06-30 07:26:29 -03:00
|
|
|
|
2010-02-23 09:20:58 -04:00
|
|
|
def testformat(formatstr, args, output=None, limit=None, overflowok=False):
|
2000-09-21 02:43:11 -03:00
|
|
|
if verbose:
|
|
|
|
if output:
|
2013-02-23 01:53:56 -04:00
|
|
|
print("{!a} % {!a} =? {!a} ...".format(formatstr, args, output),
|
|
|
|
end=' ')
|
2000-09-21 02:43:11 -03:00
|
|
|
else:
|
2013-02-23 01:53:56 -04:00
|
|
|
print("{!a} % {!a} works? ...".format(formatstr, args), end=' ')
|
2000-09-21 02:43:11 -03:00
|
|
|
try:
|
|
|
|
result = formatstr % args
|
|
|
|
except OverflowError:
|
|
|
|
if not overflowok:
|
|
|
|
raise
|
|
|
|
if verbose:
|
2007-02-09 01:37:30 -04:00
|
|
|
print('overflow (this is fine)')
|
2000-09-21 02:43:11 -03:00
|
|
|
else:
|
2010-02-07 09:15:37 -04:00
|
|
|
if output and limit is None and result != output:
|
Merged revisions 56301-56442 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56322 | kurt.kaiser | 2007-07-12 11:35:03 -0700 (Thu, 12 Jul 2007) | 2 lines
Replace obscure code which was failing in py3k.
................
r56323 | kurt.kaiser | 2007-07-12 11:44:12 -0700 (Thu, 12 Jul 2007) | 3 lines
1. Remove new division option
2. Update IDLE version to 3.0x
................
r56327 | kurt.kaiser | 2007-07-12 12:20:20 -0700 (Thu, 12 Jul 2007) | 5 lines
Fix another instance of this defect in Tkinter, and one in IDLE.
Patch 1724999 by Ali Gholami Rudi -- avoid complaints about dict size
change during iter in destroy call.
................
r56339 | georg.brandl | 2007-07-13 03:07:25 -0700 (Fri, 13 Jul 2007) | 2 lines
Fix #1753310: regrtest -x doesn't work anymore
................
r56361 | kurt.kaiser | 2007-07-13 18:25:24 -0700 (Fri, 13 Jul 2007) | 2 lines
convert a map() iterator to a list to get this working.
................
r56362 | kurt.kaiser | 2007-07-13 18:53:45 -0700 (Fri, 13 Jul 2007) | 2 lines
Was modifying dict during iteration.
................
r56376 | collin.winter | 2007-07-14 11:56:19 -0700 (Sat, 14 Jul 2007) | 1 line
Add an example of class decorators to test_grammar.
................
r56377 | collin.winter | 2007-07-14 12:00:17 -0700 (Sat, 14 Jul 2007) | 1 line
Add a basic example of dictcomps to test_grammar.
................
r56413 | neal.norwitz | 2007-07-17 00:21:18 -0700 (Tue, 17 Jul 2007) | 149 lines
Merged revisions 56202-56412 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56204 | ronald.oussoren | 2007-07-08 23:02:21 -0700 (Sun, 08 Jul 2007) | 2 lines
Patch 1693258: Fix for duplicate "preferences" menu-OS X
........
r56207 | ronald.oussoren | 2007-07-09 01:41:15 -0700 (Mon, 09 Jul 2007) | 4 lines
Patch 1673122: be explicit about which libtool to use, to avoid name clashes
when a users install GNU libtool early in his PATH
........
r56280 | georg.brandl | 2007-07-11 12:41:49 -0700 (Wed, 11 Jul 2007) | 2 lines
Fix #1752132: wrong comment in opcode description.
........
r56293 | georg.brandl | 2007-07-12 01:05:45 -0700 (Thu, 12 Jul 2007) | 3 lines
Patch #1752270, #1750931: complain if urllib2 add_handler called
without handler.
........
r56296 | georg.brandl | 2007-07-12 01:11:29 -0700 (Thu, 12 Jul 2007) | 2 lines
Patch #1739696: use code.co_code only if really necessary
........
r56298 | georg.brandl | 2007-07-12 01:38:00 -0700 (Thu, 12 Jul 2007) | 3 lines
Patch #1673759: add a missing overflow check when formatting floats
with %G.
........
r56302 | georg.brandl | 2007-07-12 02:06:41 -0700 (Thu, 12 Jul 2007) | 2 lines
Patch #1731659: improve time.strptime docs.
........
r56304 | georg.brandl | 2007-07-12 02:24:04 -0700 (Thu, 12 Jul 2007) | 2 lines
Patch #1731169: clean up expected skips list.
........
r56306 | georg.brandl | 2007-07-12 02:37:49 -0700 (Thu, 12 Jul 2007) | 3 lines
Bug #1637365: add subsection about "__name__ == __main__" to the
Python tutorial.
........
r56308 | georg.brandl | 2007-07-12 02:59:22 -0700 (Thu, 12 Jul 2007) | 5 lines
Patch #1675424: Added tests for uncovered code in the zipfile module.
The KeyError raised by Zipfile.getinfo for nonexistent names now has
a descriptive message.
........
r56340 | facundo.batista | 2007-07-13 03:43:44 -0700 (Fri, 13 Jul 2007) | 6 lines
Added tests for basic behavior of DateTime, Binary, and Fault classes
and the escape function. Check that marshalling recursive sequences &
dicts raises TypeError. Check that marshalling out-of-range ints
raises OverflowError [Alan McIntyre - GSoC]
........
r56345 | raymond.hettinger | 2007-07-13 05:09:41 -0700 (Fri, 13 Jul 2007) | 1 line
Correct the docs for takewhile(). Improve the recipe for nth(). Should be backported
........
r56348 | thomas.heller | 2007-07-13 06:59:39 -0700 (Fri, 13 Jul 2007) | 4 lines
Repair COMError. Since exceptions are new style classes now, setting
the methods and docstring after the type creation does not work, they
must be in the dictionary before creating the type.
........
r56349 | thomas.heller | 2007-07-13 07:18:06 -0700 (Fri, 13 Jul 2007) | 1 line
Add tests for _ctypes.COMError.
........
r56350 | thomas.heller | 2007-07-13 09:50:43 -0700 (Fri, 13 Jul 2007) | 4 lines
Do not try to load the GLUT library in the ctypes tests. This test
adds little value, but has a large problem on OS X, as explained in
SF# 1581906.
........
r56352 | thomas.heller | 2007-07-13 10:12:23 -0700 (Fri, 13 Jul 2007) | 3 lines
Fix for SF# 1701409: segfault in c_char_p of ctypes. The repr output
of c_char_p and c_wchar_p has changed as a sideeffect.
........
r56355 | thomas.heller | 2007-07-13 10:46:54 -0700 (Fri, 13 Jul 2007) | 3 lines
Fix for SF# 1649098: avoid zero-sized array declaration in structure.
........
r56357 | thomas.heller | 2007-07-13 12:51:55 -0700 (Fri, 13 Jul 2007) | 3 lines
PyType_stgdict() returns a borrowed reference which must not be
Py_DECREF'd.
........
r56360 | barry.warsaw | 2007-07-13 15:12:58 -0700 (Fri, 13 Jul 2007) | 10 lines
In response to this SF bug:
[ 1752723 ] email.message_from_string: initial line gets discarded
I added a test to assert that when the first line of text passed to
message_from_string() contains a leading space, the message ends up with the
appropriate FirstHeaderLineIsContinuationDefect on its defects list.
The bug is invalid.
........
r56364 | georg.brandl | 2007-07-14 10:12:23 -0700 (Sat, 14 Jul 2007) | 2 lines
Bug #1753406: missing \versionadded for subprocess.check_call.
........
r56366 | georg.brandl | 2007-07-14 10:32:41 -0700 (Sat, 14 Jul 2007) | 2 lines
Clarify webbrowser.open description.
........
r56380 | andrew.kuchling | 2007-07-14 13:58:21 -0700 (Sat, 14 Jul 2007) | 1 line
Typo fix
........
r56382 | andrew.kuchling | 2007-07-14 14:56:19 -0700 (Sat, 14 Jul 2007) | 7 lines
Avoid exception if there's a stray directory inside a Maildir folder.
The Maildir specification doesn't seem to say anything about this
situation, and it can happen if you're keeping a Maildir mailbox in
Subversion (.svn directories) or some similar system. The patch just
ignores directories in the cur/, new/, tmp/ folders.
........
r56392 | facundo.batista | 2007-07-14 15:41:45 -0700 (Sat, 14 Jul 2007) | 6 lines
First version. Includes tests for helper functions: read, write,
_exception, readwrite, closeall, compact_traceback; and for classes
dispatcher, dispatcher_with_send, and file_wrapper.
[Alan McIntyre - GSoC]
........
r56399 | facundo.batista | 2007-07-15 13:30:39 -0700 (Sun, 15 Jul 2007) | 5 lines
Changed the used port and commented out some tests that uses
a non documented function that appers to uses resources
not present in Windows.
........
r56412 | facundo.batista | 2007-07-16 19:19:39 -0700 (Mon, 16 Jul 2007) | 6 lines
Prevent asyncore.dispatcher tests from hanging by adding loop counters
to server & client, and by adding asyncore.close_all calls in
tearDown. Also choose correct expected logging results based on the
value of __debug__ [Alan McIntyre - GSoC]
........
................
r56442 | guido.van.rossum | 2007-07-18 10:26:38 -0700 (Wed, 18 Jul 2007) | 14 lines
Merged revisions 56413-56441 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56439 | georg.brandl | 2007-07-17 23:37:55 -0700 (Tue, 17 Jul 2007) | 2 lines
Use "Unix" as platform name, not "UNIX".
........
r56441 | guido.van.rossum | 2007-07-18 10:19:14 -0700 (Wed, 18 Jul 2007) | 3 lines
SF patch# 1755885 by Kurt Kaiser: show location of Unicode escape errors.
(Slightly tweaked for style and refcounts.)
........
................
2007-07-18 15:15:48 -03:00
|
|
|
if verbose:
|
|
|
|
print('no')
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
raise AssertionError("%r %% %r == %r != %r" %
|
|
|
|
(formatstr, args, result, output))
|
Merged revisions 61034-61036,61038-61048 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61034 | georg.brandl | 2008-02-24 01:03:22 +0100 (Sun, 24 Feb 2008) | 4 lines
#900744: If an invalid chunked-encoding header is sent by a server,
httplib will now raise IncompleteRead and close the connection instead
of raising ValueError.
........
r61035 | georg.brandl | 2008-02-24 01:14:24 +0100 (Sun, 24 Feb 2008) | 2 lines
#1627: httplib now ignores negative Content-Length headers.
........
r61039 | andrew.kuchling | 2008-02-24 03:39:15 +0100 (Sun, 24 Feb 2008) | 1 line
Remove stray word
........
r61040 | neal.norwitz | 2008-02-24 03:40:58 +0100 (Sun, 24 Feb 2008) | 3 lines
Add a little info to the 3k deprecation warnings about what to use instead.
Suggested by Raymond Hettinger.
........
r61041 | facundo.batista | 2008-02-24 04:17:21 +0100 (Sun, 24 Feb 2008) | 4 lines
Issue 1742669. Now %d accepts very big float numbers.
Thanks Gabriel Genellina.
........
r61046 | neal.norwitz | 2008-02-24 08:21:56 +0100 (Sun, 24 Feb 2008) | 5 lines
Get ctypes working on the Alpha (Tru64). The problem was that there
were two module_methods and the one used depended on the order the
modules were loaded. By making the test module_methods static,
it is not exported and the correct version is picked up.
........
r61048 | neal.norwitz | 2008-02-24 09:27:49 +0100 (Sun, 24 Feb 2008) | 1 line
Fix typo of hexidecimal
........
2008-02-24 09:08:18 -04:00
|
|
|
# when 'limit' is specified, it determines how many characters
|
|
|
|
# must match exactly; lengths must always match.
|
|
|
|
# ex: limit=5, '12345678' matches '12345___'
|
|
|
|
# (mainly for floating point format tests for which an exact match
|
|
|
|
# can't be guaranteed due to rounding and representation errors)
|
|
|
|
elif output and limit is not None and (
|
|
|
|
len(result)!=len(output) or result[:limit]!=output[:limit]):
|
|
|
|
if verbose:
|
|
|
|
print('no')
|
|
|
|
print("%s %% %s == %s != %s" % \
|
|
|
|
(repr(formatstr), repr(args), repr(result), repr(output)))
|
2000-09-21 02:43:11 -03:00
|
|
|
else:
|
|
|
|
if verbose:
|
2007-02-09 01:37:30 -04:00
|
|
|
print('yes')
|
2000-06-30 07:26:29 -03:00
|
|
|
|
2015-01-24 00:05:18 -04:00
|
|
|
def testcommon(formatstr, args, output=None, limit=None, overflowok=False):
|
|
|
|
# if formatstr is a str, test str, bytes, and bytearray;
|
2019-08-30 17:42:54 -03:00
|
|
|
# otherwise, test bytes and bytearray
|
2015-01-24 00:05:18 -04:00
|
|
|
if isinstance(formatstr, str):
|
|
|
|
testformat(formatstr, args, output, limit, overflowok)
|
|
|
|
b_format = formatstr.encode('ascii')
|
|
|
|
else:
|
|
|
|
b_format = formatstr
|
|
|
|
ba_format = bytearray(b_format)
|
|
|
|
b_args = []
|
|
|
|
if not isinstance(args, tuple):
|
|
|
|
args = (args, )
|
|
|
|
b_args = tuple(args)
|
|
|
|
if output is None:
|
|
|
|
b_output = ba_output = None
|
|
|
|
else:
|
|
|
|
if isinstance(output, str):
|
|
|
|
b_output = output.encode('ascii')
|
|
|
|
else:
|
|
|
|
b_output = output
|
|
|
|
ba_output = bytearray(b_output)
|
|
|
|
testformat(b_format, b_args, b_output, limit, overflowok)
|
|
|
|
testformat(ba_format, b_args, ba_output, limit, overflowok)
|
|
|
|
|
2017-03-07 23:51:19 -04:00
|
|
|
def test_exc(formatstr, args, exception, excmsg):
|
|
|
|
try:
|
|
|
|
testformat(formatstr, args)
|
|
|
|
except exception as exc:
|
|
|
|
if str(exc) == excmsg:
|
|
|
|
if verbose:
|
|
|
|
print("yes")
|
|
|
|
else:
|
|
|
|
if verbose: print('no')
|
|
|
|
print('Unexpected ', exception, ':', repr(str(exc)))
|
|
|
|
except:
|
|
|
|
if verbose: print('no')
|
|
|
|
print('Unexpected exception')
|
|
|
|
raise
|
|
|
|
else:
|
|
|
|
raise TestFailed('did not get expected exception: %s' % excmsg)
|
|
|
|
|
|
|
|
def test_exc_common(formatstr, args, exception, excmsg):
|
|
|
|
# test str and bytes
|
|
|
|
test_exc(formatstr, args, exception, excmsg)
|
|
|
|
test_exc(formatstr.encode('ascii'), args, exception, excmsg)
|
2000-11-30 01:22:44 -04:00
|
|
|
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
class FormatTest(unittest.TestCase):
|
2015-01-24 00:05:18 -04:00
|
|
|
|
|
|
|
def test_common_format(self):
|
|
|
|
# test the format identifiers that work the same across
|
|
|
|
# str, bytes, and bytearrays (integer, float, oct, hex)
|
2017-03-07 23:51:19 -04:00
|
|
|
testcommon("%%", (), "%")
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%.1d", (1,), "1")
|
|
|
|
testcommon("%.*d", (sys.maxsize,1), overflowok=True) # expect overflow
|
|
|
|
testcommon("%.100d", (1,), '00000000000000000000000000000000000000'
|
2010-02-23 09:20:58 -04:00
|
|
|
'000000000000000000000000000000000000000000000000000000'
|
|
|
|
'00000001', overflowok=True)
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#.117x", (1,), '0x00000000000000000000000000000000000'
|
2010-02-23 09:20:58 -04:00
|
|
|
'000000000000000000000000000000000000000000000000000000'
|
|
|
|
'0000000000000000000000000001',
|
|
|
|
overflowok=True)
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#.118x", (1,), '0x00000000000000000000000000000000000'
|
2010-02-23 09:20:58 -04:00
|
|
|
'000000000000000000000000000000000000000000000000000000'
|
|
|
|
'00000000000000000000000000001',
|
|
|
|
overflowok=True)
|
2007-10-22 17:24:51 -03:00
|
|
|
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%f", (1.0,), "1.000000")
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
# these are trying to test the limits of the internal magic-number-length
|
|
|
|
# formatting buffer, if that number changes then these tests are less
|
|
|
|
# effective
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#.*g", (109, -1.e+49/3.))
|
|
|
|
testcommon("%#.*g", (110, -1.e+49/3.))
|
|
|
|
testcommon("%#.*g", (110, -1.e+100/3.))
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
# test some ridiculously large precision, expect overflow
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon('%12.*f', (123456, 1.0))
|
2010-02-07 09:15:37 -04:00
|
|
|
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
# check for internal overflow validation on length of precision
|
2010-02-07 09:15:37 -04:00
|
|
|
# these tests should no longer cause overflow in Python
|
|
|
|
# 2.7/3.1 and later.
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#.*g", (110, -1.e+100/3.))
|
|
|
|
testcommon("%#.*G", (110, -1.e+100/3.))
|
|
|
|
testcommon("%#.*f", (110, -1.e+100/3.))
|
|
|
|
testcommon("%#.*F", (110, -1.e+100/3.))
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
# Formatting of integers. Overflow is not ok
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%x", 10, "a")
|
|
|
|
testcommon("%x", 100000000000, "174876e800")
|
|
|
|
testcommon("%o", 10, "12")
|
|
|
|
testcommon("%o", 100000000000, "1351035564000")
|
|
|
|
testcommon("%d", 10, "10")
|
|
|
|
testcommon("%d", 100000000000, "100000000000")
|
2016-12-17 15:48:03 -04:00
|
|
|
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
big = 123456789012345678901234567890
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%d", big, "123456789012345678901234567890")
|
|
|
|
testcommon("%d", -big, "-123456789012345678901234567890")
|
|
|
|
testcommon("%5d", -big, "-123456789012345678901234567890")
|
|
|
|
testcommon("%31d", -big, "-123456789012345678901234567890")
|
|
|
|
testcommon("%32d", -big, " -123456789012345678901234567890")
|
|
|
|
testcommon("%-32d", -big, "-123456789012345678901234567890 ")
|
|
|
|
testcommon("%032d", -big, "-0123456789012345678901234567890")
|
|
|
|
testcommon("%-032d", -big, "-123456789012345678901234567890 ")
|
|
|
|
testcommon("%034d", -big, "-000123456789012345678901234567890")
|
|
|
|
testcommon("%034d", big, "0000123456789012345678901234567890")
|
|
|
|
testcommon("%0+34d", big, "+000123456789012345678901234567890")
|
|
|
|
testcommon("%+34d", big, " +123456789012345678901234567890")
|
|
|
|
testcommon("%34d", big, " 123456789012345678901234567890")
|
|
|
|
testcommon("%.2d", big, "123456789012345678901234567890")
|
|
|
|
testcommon("%.30d", big, "123456789012345678901234567890")
|
|
|
|
testcommon("%.31d", big, "0123456789012345678901234567890")
|
|
|
|
testcommon("%32.31d", big, " 0123456789012345678901234567890")
|
|
|
|
testcommon("%d", float(big), "123456________________________", 6)
|
2016-12-17 15:48:03 -04:00
|
|
|
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
big = 0x1234567890abcdef12345 # 21 hex digits
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%x", big, "1234567890abcdef12345")
|
|
|
|
testcommon("%x", -big, "-1234567890abcdef12345")
|
|
|
|
testcommon("%5x", -big, "-1234567890abcdef12345")
|
|
|
|
testcommon("%22x", -big, "-1234567890abcdef12345")
|
|
|
|
testcommon("%23x", -big, " -1234567890abcdef12345")
|
|
|
|
testcommon("%-23x", -big, "-1234567890abcdef12345 ")
|
|
|
|
testcommon("%023x", -big, "-01234567890abcdef12345")
|
|
|
|
testcommon("%-023x", -big, "-1234567890abcdef12345 ")
|
|
|
|
testcommon("%025x", -big, "-0001234567890abcdef12345")
|
|
|
|
testcommon("%025x", big, "00001234567890abcdef12345")
|
|
|
|
testcommon("%0+25x", big, "+0001234567890abcdef12345")
|
|
|
|
testcommon("%+25x", big, " +1234567890abcdef12345")
|
|
|
|
testcommon("%25x", big, " 1234567890abcdef12345")
|
|
|
|
testcommon("%.2x", big, "1234567890abcdef12345")
|
|
|
|
testcommon("%.21x", big, "1234567890abcdef12345")
|
|
|
|
testcommon("%.22x", big, "01234567890abcdef12345")
|
|
|
|
testcommon("%23.22x", big, " 01234567890abcdef12345")
|
|
|
|
testcommon("%-23.22x", big, "01234567890abcdef12345 ")
|
|
|
|
testcommon("%X", big, "1234567890ABCDEF12345")
|
|
|
|
testcommon("%#X", big, "0X1234567890ABCDEF12345")
|
|
|
|
testcommon("%#x", big, "0x1234567890abcdef12345")
|
|
|
|
testcommon("%#x", -big, "-0x1234567890abcdef12345")
|
2016-12-17 15:48:03 -04:00
|
|
|
testcommon("%#27x", big, " 0x1234567890abcdef12345")
|
|
|
|
testcommon("%#-27x", big, "0x1234567890abcdef12345 ")
|
|
|
|
testcommon("%#027x", big, "0x00001234567890abcdef12345")
|
|
|
|
testcommon("%#.23x", big, "0x001234567890abcdef12345")
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#.23x", -big, "-0x001234567890abcdef12345")
|
2016-12-17 15:48:03 -04:00
|
|
|
testcommon("%#27.23x", big, " 0x001234567890abcdef12345")
|
|
|
|
testcommon("%#-27.23x", big, "0x001234567890abcdef12345 ")
|
|
|
|
testcommon("%#027.23x", big, "0x00001234567890abcdef12345")
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#+.23x", big, "+0x001234567890abcdef12345")
|
|
|
|
testcommon("%# .23x", big, " 0x001234567890abcdef12345")
|
|
|
|
testcommon("%#+.23X", big, "+0X001234567890ABCDEF12345")
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
# next one gets two leading zeroes from precision, and another from the
|
|
|
|
# 0 flag and the width
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#+027.23X", big, "+0X0001234567890ABCDEF12345")
|
2016-12-17 15:48:03 -04:00
|
|
|
testcommon("%# 027.23X", big, " 0X0001234567890ABCDEF12345")
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
# same, except no 0 flag
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#+27.23X", big, " +0X001234567890ABCDEF12345")
|
2016-12-17 15:48:03 -04:00
|
|
|
testcommon("%#-+27.23x", big, "+0x001234567890abcdef12345 ")
|
|
|
|
testcommon("%#- 27.23x", big, " 0x001234567890abcdef12345 ")
|
|
|
|
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
big = 0o12345670123456701234567012345670 # 32 octal digits
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%o", big, "12345670123456701234567012345670")
|
|
|
|
testcommon("%o", -big, "-12345670123456701234567012345670")
|
|
|
|
testcommon("%5o", -big, "-12345670123456701234567012345670")
|
|
|
|
testcommon("%33o", -big, "-12345670123456701234567012345670")
|
|
|
|
testcommon("%34o", -big, " -12345670123456701234567012345670")
|
|
|
|
testcommon("%-34o", -big, "-12345670123456701234567012345670 ")
|
|
|
|
testcommon("%034o", -big, "-012345670123456701234567012345670")
|
|
|
|
testcommon("%-034o", -big, "-12345670123456701234567012345670 ")
|
|
|
|
testcommon("%036o", -big, "-00012345670123456701234567012345670")
|
|
|
|
testcommon("%036o", big, "000012345670123456701234567012345670")
|
|
|
|
testcommon("%0+36o", big, "+00012345670123456701234567012345670")
|
|
|
|
testcommon("%+36o", big, " +12345670123456701234567012345670")
|
|
|
|
testcommon("%36o", big, " 12345670123456701234567012345670")
|
|
|
|
testcommon("%.2o", big, "12345670123456701234567012345670")
|
|
|
|
testcommon("%.32o", big, "12345670123456701234567012345670")
|
|
|
|
testcommon("%.33o", big, "012345670123456701234567012345670")
|
|
|
|
testcommon("%34.33o", big, " 012345670123456701234567012345670")
|
|
|
|
testcommon("%-34.33o", big, "012345670123456701234567012345670 ")
|
|
|
|
testcommon("%o", big, "12345670123456701234567012345670")
|
|
|
|
testcommon("%#o", big, "0o12345670123456701234567012345670")
|
|
|
|
testcommon("%#o", -big, "-0o12345670123456701234567012345670")
|
2016-12-17 15:48:03 -04:00
|
|
|
testcommon("%#38o", big, " 0o12345670123456701234567012345670")
|
|
|
|
testcommon("%#-38o", big, "0o12345670123456701234567012345670 ")
|
|
|
|
testcommon("%#038o", big, "0o000012345670123456701234567012345670")
|
|
|
|
testcommon("%#.34o", big, "0o0012345670123456701234567012345670")
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#.34o", -big, "-0o0012345670123456701234567012345670")
|
2016-12-17 15:48:03 -04:00
|
|
|
testcommon("%#38.34o", big, " 0o0012345670123456701234567012345670")
|
|
|
|
testcommon("%#-38.34o", big, "0o0012345670123456701234567012345670 ")
|
|
|
|
testcommon("%#038.34o", big, "0o000012345670123456701234567012345670")
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#+.34o", big, "+0o0012345670123456701234567012345670")
|
|
|
|
testcommon("%# .34o", big, " 0o0012345670123456701234567012345670")
|
2016-12-17 15:48:03 -04:00
|
|
|
testcommon("%#+38.34o", big, " +0o0012345670123456701234567012345670")
|
|
|
|
testcommon("%#-+38.34o", big, "+0o0012345670123456701234567012345670 ")
|
|
|
|
testcommon("%#- 38.34o", big, " 0o0012345670123456701234567012345670 ")
|
|
|
|
testcommon("%#+038.34o", big, "+0o00012345670123456701234567012345670")
|
|
|
|
testcommon("%# 038.34o", big, " 0o00012345670123456701234567012345670")
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
# next one gets one leading zero from precision
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%.33o", big, "012345670123456701234567012345670")
|
2016-12-10 21:07:29 -04:00
|
|
|
# base marker added in spite of leading zero (different to Python 2)
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#.33o", big, "0o012345670123456701234567012345670")
|
2016-12-10 21:07:29 -04:00
|
|
|
# reduce precision, and base marker is always added
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%#.32o", big, "0o12345670123456701234567012345670")
|
2016-12-10 21:07:29 -04:00
|
|
|
# one leading zero from precision, plus two from "0" flag & width
|
|
|
|
testcommon("%035.33o", big, "00012345670123456701234567012345670")
|
|
|
|
# base marker shouldn't change the size
|
|
|
|
testcommon("%0#35.33o", big, "0o012345670123456701234567012345670")
|
2016-12-17 15:48:03 -04:00
|
|
|
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
# Some small ints, in both Python int and flavors).
|
2015-01-24 00:05:18 -04:00
|
|
|
testcommon("%d", 42, "42")
|
|
|
|
testcommon("%d", -42, "-42")
|
|
|
|
testcommon("%d", 42.0, "42")
|
|
|
|
testcommon("%#x", 1, "0x1")
|
|
|
|
testcommon("%#X", 1, "0X1")
|
|
|
|
testcommon("%#o", 1, "0o1")
|
|
|
|
testcommon("%#o", 0, "0o0")
|
|
|
|
testcommon("%o", 0, "0")
|
|
|
|
testcommon("%d", 0, "0")
|
|
|
|
testcommon("%#x", 0, "0x0")
|
|
|
|
testcommon("%#X", 0, "0X0")
|
|
|
|
testcommon("%x", 0x42, "42")
|
|
|
|
testcommon("%x", -0x42, "-42")
|
|
|
|
testcommon("%o", 0o42, "42")
|
|
|
|
testcommon("%o", -0o42, "-42")
|
|
|
|
# alternate float formatting
|
|
|
|
testcommon('%g', 1.1, '1.1')
|
|
|
|
testcommon('%#g', 1.1, '1.10000')
|
|
|
|
|
2017-03-07 23:51:19 -04:00
|
|
|
if verbose:
|
|
|
|
print('Testing exceptions')
|
|
|
|
test_exc_common('%', (), ValueError, "incomplete format")
|
|
|
|
test_exc_common('% %s', 1, ValueError,
|
|
|
|
"unsupported format character '%' (0x25) at index 2")
|
|
|
|
test_exc_common('%d', '1', TypeError,
|
|
|
|
"%d format: a number is required, not str")
|
|
|
|
test_exc_common('%d', b'1', TypeError,
|
|
|
|
"%d format: a number is required, not bytes")
|
|
|
|
test_exc_common('%x', '1', TypeError,
|
|
|
|
"%x format: an integer is required, not str")
|
|
|
|
test_exc_common('%x', 3.14, TypeError,
|
|
|
|
"%x format: an integer is required, not float")
|
|
|
|
|
2015-01-24 00:05:18 -04:00
|
|
|
def test_str_format(self):
|
2008-09-10 20:51:42 -03:00
|
|
|
testformat("%r", "\u0378", "'\\u0378'") # non printable
|
|
|
|
testformat("%a", "\u0378", "'\\u0378'") # non printable
|
2008-07-04 14:57:09 -03:00
|
|
|
testformat("%r", "\u0374", "'\u0374'") # printable
|
|
|
|
testformat("%a", "\u0374", "'\\u0374'") # printable
|
2009-04-16 17:16:10 -03:00
|
|
|
|
2015-01-24 00:05:18 -04:00
|
|
|
# Test exception for unknown format characters, etc.
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
if verbose:
|
|
|
|
print('Testing exceptions')
|
2008-06-11 15:37:52 -03:00
|
|
|
test_exc('abc %b', 1, ValueError,
|
|
|
|
"unsupported format character 'b' (0x62) at index 5")
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
#test_exc(unicode('abc %\u3000','raw-unicode-escape'), 1, ValueError,
|
|
|
|
# "unsupported format character '?' (0x3000) at index 5")
|
2016-06-06 07:00:03 -03:00
|
|
|
test_exc('%g', '1', TypeError, "must be real number, not str")
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
test_exc('no format', '1', TypeError,
|
|
|
|
"not all arguments converted during string formatting")
|
2015-03-30 03:19:08 -03:00
|
|
|
test_exc('%c', -1, OverflowError, "%c arg not in range(0x110000)")
|
|
|
|
test_exc('%c', sys.maxunicode+1, OverflowError,
|
|
|
|
"%c arg not in range(0x110000)")
|
|
|
|
#test_exc('%c', 2**128, OverflowError, "%c arg not in range(0x110000)")
|
|
|
|
test_exc('%c', 3.14, TypeError, "%c requires int or char")
|
|
|
|
test_exc('%c', 'ab', TypeError, "%c requires int or char")
|
|
|
|
test_exc('%c', b'x', TypeError, "%c requires int or char")
|
2015-01-24 00:05:18 -04:00
|
|
|
|
|
|
|
if maxsize == 2**31-1:
|
|
|
|
# crashes 2.2.1 and earlier:
|
|
|
|
try:
|
|
|
|
"%*d"%(maxsize, -127)
|
|
|
|
except MemoryError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise TestFailed('"%*d"%(maxsize, -127) should fail')
|
|
|
|
|
|
|
|
def test_bytes_and_bytearray_format(self):
|
|
|
|
# %c will insert a single byte, either from an int in range(256), or
|
|
|
|
# from a bytes argument of length 1, not from a str.
|
|
|
|
testcommon(b"%c", 7, b"\x07")
|
|
|
|
testcommon(b"%c", b"Z", b"Z")
|
|
|
|
testcommon(b"%c", bytearray(b"Z"), b"Z")
|
2015-10-09 17:50:36 -03:00
|
|
|
testcommon(b"%5c", 65, b" A")
|
|
|
|
testcommon(b"%-5c", 65, b"A ")
|
2015-01-24 00:05:18 -04:00
|
|
|
# %b will insert a series of bytes, either from a type that supports
|
|
|
|
# the Py_buffer protocol, or something that has a __bytes__ method
|
|
|
|
class FakeBytes(object):
|
|
|
|
def __bytes__(self):
|
|
|
|
return b'123'
|
|
|
|
fb = FakeBytes()
|
|
|
|
testcommon(b"%b", b"abc", b"abc")
|
|
|
|
testcommon(b"%b", bytearray(b"def"), b"def")
|
|
|
|
testcommon(b"%b", fb, b"123")
|
2017-03-14 04:07:15 -03:00
|
|
|
testcommon(b"%b", memoryview(b"abc"), b"abc")
|
2015-01-24 00:05:18 -04:00
|
|
|
# # %s is an alias for %b -- should only be used for Py2/3 code
|
|
|
|
testcommon(b"%s", b"abc", b"abc")
|
|
|
|
testcommon(b"%s", bytearray(b"def"), b"def")
|
|
|
|
testcommon(b"%s", fb, b"123")
|
2017-03-14 04:07:15 -03:00
|
|
|
testcommon(b"%s", memoryview(b"abc"), b"abc")
|
2015-01-24 00:05:18 -04:00
|
|
|
# %a will give the equivalent of
|
|
|
|
# repr(some_obj).encode('ascii', 'backslashreplace')
|
|
|
|
testcommon(b"%a", 3.14, b"3.14")
|
|
|
|
testcommon(b"%a", b"ghi", b"b'ghi'")
|
|
|
|
testcommon(b"%a", "jkl", b"'jkl'")
|
|
|
|
testcommon(b"%a", "\u0544", b"'\\u0544'")
|
2015-03-11 12:17:00 -03:00
|
|
|
# %r is an alias for %a
|
|
|
|
testcommon(b"%r", 3.14, b"3.14")
|
|
|
|
testcommon(b"%r", b"ghi", b"b'ghi'")
|
|
|
|
testcommon(b"%r", "jkl", b"'jkl'")
|
|
|
|
testcommon(b"%r", "\u0544", b"'\\u0544'")
|
2015-01-24 00:05:18 -04:00
|
|
|
|
|
|
|
# Test exception for unknown format characters, etc.
|
|
|
|
if verbose:
|
|
|
|
print('Testing exceptions')
|
|
|
|
test_exc(b'%g', '1', TypeError, "float argument required, not str")
|
|
|
|
test_exc(b'%g', b'1', TypeError, "float argument required, not bytes")
|
|
|
|
test_exc(b'no format', 7, TypeError,
|
|
|
|
"not all arguments converted during bytes formatting")
|
|
|
|
test_exc(b'no format', b'1', TypeError,
|
|
|
|
"not all arguments converted during bytes formatting")
|
|
|
|
test_exc(b'no format', bytearray(b'1'), TypeError,
|
|
|
|
"not all arguments converted during bytes formatting")
|
2015-04-03 14:53:46 -03:00
|
|
|
test_exc(b"%c", -1, OverflowError,
|
|
|
|
"%c arg not in range(256)")
|
|
|
|
test_exc(b"%c", 256, OverflowError,
|
|
|
|
"%c arg not in range(256)")
|
|
|
|
test_exc(b"%c", 2**128, OverflowError,
|
|
|
|
"%c arg not in range(256)")
|
2015-01-24 00:05:18 -04:00
|
|
|
test_exc(b"%c", b"Za", TypeError,
|
|
|
|
"%c requires an integer in range(256) or a single byte")
|
2015-03-30 03:19:08 -03:00
|
|
|
test_exc(b"%c", "Y", TypeError,
|
|
|
|
"%c requires an integer in range(256) or a single byte")
|
|
|
|
test_exc(b"%c", 3.14, TypeError,
|
2015-01-24 00:05:18 -04:00
|
|
|
"%c requires an integer in range(256) or a single byte")
|
|
|
|
test_exc(b"%b", "Xc", TypeError,
|
2017-03-14 04:07:15 -03:00
|
|
|
"%b requires a bytes-like object, "
|
|
|
|
"or an object that implements __bytes__, not 'str'")
|
2015-01-24 00:05:18 -04:00
|
|
|
test_exc(b"%s", "Wd", TypeError,
|
2017-03-14 04:07:15 -03:00
|
|
|
"%b requires a bytes-like object, "
|
|
|
|
"or an object that implements __bytes__, not 'str'")
|
2007-10-22 17:24:51 -03:00
|
|
|
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
if maxsize == 2**31-1:
|
|
|
|
# crashes 2.2.1 and earlier:
|
|
|
|
try:
|
|
|
|
"%*d"%(maxsize, -127)
|
|
|
|
except MemoryError:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise TestFailed('"%*d"%(maxsize, -127) should fail')
|
2000-12-15 09:09:06 -04:00
|
|
|
|
2016-12-28 03:54:22 -04:00
|
|
|
def test_nul(self):
|
|
|
|
# test the null character
|
|
|
|
testcommon("a\0b", (), 'a\0b')
|
|
|
|
testcommon("a%cb", (0,), 'a\0b')
|
|
|
|
testformat("a%sb", ('c\0d',), 'ac\0db')
|
|
|
|
testcommon(b"a%sb", (b'c\0d',), b'ac\0db')
|
|
|
|
|
2012-01-21 10:50:49 -04:00
|
|
|
def test_non_ascii(self):
|
2012-06-15 21:57:41 -03:00
|
|
|
testformat("\u20ac=%f", (1.0,), "\u20ac=1.000000")
|
|
|
|
|
2012-01-21 10:50:49 -04:00
|
|
|
self.assertEqual(format("abc", "\u2007<5"), "abc\u2007\u2007")
|
|
|
|
self.assertEqual(format(123, "\u2007<5"), "123\u2007\u2007")
|
|
|
|
self.assertEqual(format(12.3, "\u2007<6"), "12.3\u2007\u2007")
|
|
|
|
self.assertEqual(format(0j, "\u2007<4"), "0j\u2007\u2007")
|
|
|
|
self.assertEqual(format(1+2j, "\u2007<8"), "(1+2j)\u2007\u2007")
|
|
|
|
|
|
|
|
self.assertEqual(format("abc", "\u2007>5"), "\u2007\u2007abc")
|
|
|
|
self.assertEqual(format(123, "\u2007>5"), "\u2007\u2007123")
|
|
|
|
self.assertEqual(format(12.3, "\u2007>6"), "\u2007\u200712.3")
|
|
|
|
self.assertEqual(format(1+2j, "\u2007>8"), "\u2007\u2007(1+2j)")
|
|
|
|
self.assertEqual(format(0j, "\u2007>4"), "\u2007\u20070j")
|
|
|
|
|
|
|
|
self.assertEqual(format("abc", "\u2007^5"), "\u2007abc\u2007")
|
|
|
|
self.assertEqual(format(123, "\u2007^5"), "\u2007123\u2007")
|
|
|
|
self.assertEqual(format(12.3, "\u2007^6"), "\u200712.3\u2007")
|
|
|
|
self.assertEqual(format(1+2j, "\u2007^8"), "\u2007(1+2j)\u2007")
|
|
|
|
self.assertEqual(format(0j, "\u2007^4"), "\u20070j\u2007")
|
|
|
|
|
2012-02-23 19:37:51 -04:00
|
|
|
def test_locale(self):
|
|
|
|
try:
|
2012-02-27 05:18:51 -04:00
|
|
|
oldloc = locale.setlocale(locale.LC_ALL)
|
|
|
|
locale.setlocale(locale.LC_ALL, '')
|
2012-02-23 19:37:51 -04:00
|
|
|
except locale.Error as err:
|
|
|
|
self.skipTest("Cannot set locale: {}".format(err))
|
|
|
|
try:
|
2012-02-23 20:44:47 -04:00
|
|
|
localeconv = locale.localeconv()
|
|
|
|
sep = localeconv['thousands_sep']
|
|
|
|
point = localeconv['decimal_point']
|
|
|
|
|
2012-02-23 19:37:51 -04:00
|
|
|
text = format(123456789, "n")
|
|
|
|
self.assertIn(sep, text)
|
|
|
|
self.assertEqual(text.replace(sep, ''), '123456789')
|
2012-02-23 20:44:47 -04:00
|
|
|
|
|
|
|
text = format(1234.5, "n")
|
|
|
|
self.assertIn(sep, text)
|
|
|
|
self.assertIn(point, text)
|
|
|
|
self.assertEqual(text.replace(sep, ''), '1234' + point + '5')
|
2012-02-23 19:37:51 -04:00
|
|
|
finally:
|
|
|
|
locale.setlocale(locale.LC_ALL, oldloc)
|
|
|
|
|
2012-10-01 19:33:47 -03:00
|
|
|
@support.cpython_only
|
|
|
|
def test_optimisations(self):
|
|
|
|
text = "abcde" # 5 characters
|
|
|
|
|
|
|
|
self.assertIs("%s" % text, text)
|
|
|
|
self.assertIs("%.5s" % text, text)
|
|
|
|
self.assertIs("%.10s" % text, text)
|
|
|
|
self.assertIs("%1s" % text, text)
|
|
|
|
self.assertIs("%5s" % text, text)
|
|
|
|
|
|
|
|
self.assertIs("{0}".format(text), text)
|
|
|
|
self.assertIs("{0:s}".format(text), text)
|
|
|
|
self.assertIs("{0:.5s}".format(text), text)
|
|
|
|
self.assertIs("{0:.10s}".format(text), text)
|
|
|
|
self.assertIs("{0:1s}".format(text), text)
|
|
|
|
self.assertIs("{0:5s}".format(text), text)
|
2012-02-23 19:37:51 -04:00
|
|
|
|
2013-04-02 20:48:39 -03:00
|
|
|
self.assertIs(text % (), text)
|
|
|
|
self.assertIs(text.format(), text)
|
|
|
|
|
2013-06-23 09:54:30 -03:00
|
|
|
def test_precision(self):
|
|
|
|
f = 1.2
|
|
|
|
self.assertEqual(format(f, ".0f"), "1")
|
|
|
|
self.assertEqual(format(f, ".3f"), "1.200")
|
|
|
|
with self.assertRaises(ValueError) as cm:
|
2014-02-07 04:06:39 -04:00
|
|
|
format(f, ".%sf" % (sys.maxsize + 1))
|
2013-06-23 09:54:30 -03:00
|
|
|
|
|
|
|
c = complex(f)
|
2013-10-13 07:04:36 -03:00
|
|
|
self.assertEqual(format(c, ".0f"), "1+0j")
|
|
|
|
self.assertEqual(format(c, ".3f"), "1.200+0.000j")
|
2013-06-23 09:54:30 -03:00
|
|
|
with self.assertRaises(ValueError) as cm:
|
2014-02-07 04:06:39 -04:00
|
|
|
format(c, ".%sf" % (sys.maxsize + 1))
|
2013-06-23 09:54:30 -03:00
|
|
|
|
2014-02-07 04:06:39 -04:00
|
|
|
@support.cpython_only
|
|
|
|
def test_precision_c_limits(self):
|
|
|
|
from _testcapi import INT_MAX
|
|
|
|
|
|
|
|
f = 1.2
|
|
|
|
with self.assertRaises(ValueError) as cm:
|
|
|
|
format(f, ".%sf" % (INT_MAX + 1))
|
|
|
|
|
|
|
|
c = complex(f)
|
2013-06-23 09:54:30 -03:00
|
|
|
with self.assertRaises(ValueError) as cm:
|
2013-10-13 07:04:36 -03:00
|
|
|
format(c, ".%sf" % (INT_MAX + 1))
|
2013-06-23 09:54:30 -03:00
|
|
|
|
2000-12-15 09:09:06 -04:00
|
|
|
|
Merged revisions 61913,61915-61916,61918-61919,61922-61926,61928-61929,61931,61935,61938,61943 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r61913 | benjamin.peterson | 2008-03-25 22:14:42 +0100 (Tue, 25 Mar 2008) | 2 lines
Merged the ACKS from py3k
........
r61915 | thomas.heller | 2008-03-25 22:18:39 +0100 (Tue, 25 Mar 2008) | 1 line
Make _ctypes.c PY_SSIZE_T_CLEAN.
........
r61916 | benjamin.peterson | 2008-03-25 22:55:50 +0100 (Tue, 25 Mar 2008) | 3 lines
Opps! I merged the revisions, but forgot to add
the header to ACKS
........
r61918 | andrew.kuchling | 2008-03-26 01:16:50 +0100 (Wed, 26 Mar 2008) | 1 line
Minor docstring typos
........
r61919 | andrew.kuchling | 2008-03-26 01:30:02 +0100 (Wed, 26 Mar 2008) | 1 line
Add various items
........
r61922 | neal.norwitz | 2008-03-26 05:55:51 +0100 (Wed, 26 Mar 2008) | 6 lines
Try to get this test to be less flaky. It was failing sometimes because
the connect would succeed before the timeout occurred. Try using an
address and port that hopefully doesn't exist to ensure we get no response.
If this doesn't work, we can use a public address close to python.org
and hopefully that address never gets taken.
........
r61923 | jerry.seutter | 2008-03-26 06:03:03 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61924 | neal.norwitz | 2008-03-26 06:19:41 +0100 (Wed, 26 Mar 2008) | 5 lines
Ensure that the mailbox is closed to prevent problems on Windows with removing
an open file. This doesn't seem to be a problem in 2.6, but that appears
to be somewhat accidental (specific to reference counting). When this
gets merged to 3.0, it will make the 3.0 code simpler.
........
r61925 | jerry.seutter | 2008-03-26 06:32:51 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61926 | jerry.seutter | 2008-03-26 06:58:14 +0100 (Wed, 26 Mar 2008) | 1 line
Changed test so it no longer runs as a side effect of importing.
........
r61928 | georg.brandl | 2008-03-26 10:04:36 +0100 (Wed, 26 Mar 2008) | 2 lines
Add Josiah.
........
r61929 | georg.brandl | 2008-03-26 10:32:46 +0100 (Wed, 26 Mar 2008) | 2 lines
Add an example for an RFC 822 continuation.
........
r61931 | benjamin.peterson | 2008-03-26 12:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Added help options to PDB
........
r61935 | christian.heimes | 2008-03-26 13:32:49 +0100 (Wed, 26 Mar 2008) | 1 line
Prepare integration of bytearray backport branch
........
r61938 | christian.heimes | 2008-03-26 13:50:43 +0100 (Wed, 26 Mar 2008) | 3 lines
Removed merge tracking for "svnmerge" for
svn+ssh://pythondev@svn.python.org/python/branches/trunk-bytearray
........
r61943 | georg.brandl | 2008-03-26 13:57:47 +0100 (Wed, 26 Mar 2008) | 2 lines
Fix and simplify error handling, silencing a compiler warning.
........
2008-03-26 10:45:42 -03:00
|
|
|
if __name__ == "__main__":
|
|
|
|
unittest.main()
|