2004-01-17 10:29:29 -04:00
|
|
|
#
|
2012-04-09 10:37:52 -03:00
|
|
|
# multibytecodec_support.py
|
2004-01-17 10:29:29 -04:00
|
|
|
# Common Unittest Routines for CJK codecs
|
|
|
|
#
|
|
|
|
|
2011-05-16 11:43:38 -03:00
|
|
|
import codecs
|
|
|
|
import os
|
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
import unittest
|
2009-11-26 08:38:23 -04:00
|
|
|
from http.client import HTTPException
|
2008-05-20 18:35:26 -03:00
|
|
|
from test import support
|
2007-05-17 20:59:11 -03:00
|
|
|
from io import BytesIO
|
2004-01-17 10:29:29 -04:00
|
|
|
|
|
|
|
class TestBase:
|
|
|
|
encoding = '' # codec name
|
|
|
|
codec = None # codec tuple (with 4 elements)
|
2007-05-17 20:59:11 -03:00
|
|
|
tstring = None # must set. 2 strings to test StreamReader
|
2004-01-17 10:29:29 -04:00
|
|
|
|
|
|
|
codectests = None # must set. codec test tuple
|
|
|
|
roundtriptest = 1 # set if roundtrip is possible with unicode
|
|
|
|
has_iso10646 = 0 # set if this encoding contains whole iso10646 map
|
|
|
|
xmlcharnametest = None # string to test xmlcharrefreplace
|
2015-01-18 05:28:37 -04:00
|
|
|
unmappedunicode = '\udeee' # a unicode code point that is not mapped.
|
2004-01-17 10:29:29 -04:00
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
if self.codec is None:
|
|
|
|
self.codec = codecs.lookup(self.encoding)
|
2006-04-21 07:40:58 -03:00
|
|
|
self.encode = self.codec.encode
|
|
|
|
self.decode = self.codec.decode
|
|
|
|
self.reader = self.codec.streamreader
|
|
|
|
self.writer = self.codec.streamwriter
|
|
|
|
self.incrementalencoder = self.codec.incrementalencoder
|
|
|
|
self.incrementaldecoder = self.codec.incrementaldecoder
|
2004-01-17 10:29:29 -04:00
|
|
|
|
|
|
|
def test_chunkcoding(self):
|
2007-10-09 21:12:46 -03:00
|
|
|
tstring_lines = []
|
|
|
|
for b in self.tstring:
|
|
|
|
lines = b.split(b"\n")
|
|
|
|
last = lines.pop()
|
|
|
|
assert last == b""
|
|
|
|
lines = [line + b"\n" for line in lines]
|
|
|
|
tstring_lines.append(lines)
|
|
|
|
for native, utf8 in zip(*tstring_lines):
|
2004-01-17 10:29:29 -04:00
|
|
|
u = self.decode(native)[0]
|
|
|
|
self.assertEqual(u, utf8.decode('utf-8'))
|
|
|
|
if self.roundtriptest:
|
|
|
|
self.assertEqual(native, self.encode(u)[0])
|
|
|
|
|
|
|
|
def test_errorhandle(self):
|
|
|
|
for source, scheme, expected in self.codectests:
|
2007-05-17 20:59:11 -03:00
|
|
|
if isinstance(source, bytes):
|
2004-01-17 10:29:29 -04:00
|
|
|
func = self.decode
|
|
|
|
else:
|
|
|
|
func = self.encode
|
|
|
|
if expected:
|
|
|
|
result = func(source, scheme)[0]
|
2007-11-06 17:34:58 -04:00
|
|
|
if func is self.decode:
|
2009-06-30 20:06:06 -03:00
|
|
|
self.assertTrue(type(result) is str, type(result))
|
2011-06-03 18:44:39 -03:00
|
|
|
self.assertEqual(result, expected,
|
|
|
|
'%a.decode(%r, %r)=%a != %a'
|
|
|
|
% (source, self.encoding, scheme, result,
|
|
|
|
expected))
|
2007-11-06 17:34:58 -04:00
|
|
|
else:
|
2009-06-30 20:06:06 -03:00
|
|
|
self.assertTrue(type(result) is bytes, type(result))
|
2011-06-03 18:44:39 -03:00
|
|
|
self.assertEqual(result, expected,
|
|
|
|
'%a.encode(%r, %r)=%a != %a'
|
|
|
|
% (source, self.encoding, scheme, result,
|
|
|
|
expected))
|
2004-01-17 10:29:29 -04:00
|
|
|
else:
|
|
|
|
self.assertRaises(UnicodeError, func, source, scheme)
|
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
def test_xmlcharrefreplace(self):
|
|
|
|
if self.has_iso10646:
|
2013-12-08 02:20:35 -04:00
|
|
|
self.skipTest('encoding contains full ISO 10646 map')
|
2006-04-21 07:40:58 -03:00
|
|
|
|
2007-05-02 16:09:54 -03:00
|
|
|
s = "\u0b13\u0b23\u0b60 nd eggs"
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(
|
|
|
|
self.encode(s, "xmlcharrefreplace")[0],
|
2007-05-17 20:59:11 -03:00
|
|
|
b"ଓଣୠ nd eggs"
|
2006-04-21 07:40:58 -03:00
|
|
|
)
|
|
|
|
|
|
|
|
def test_customreplace_encode(self):
|
|
|
|
if self.has_iso10646:
|
2013-12-08 02:20:35 -04:00
|
|
|
self.skipTest('encoding contains full ISO 10646 map')
|
2006-04-21 07:40:58 -03:00
|
|
|
|
2008-05-17 19:02:32 -03:00
|
|
|
from html.entities import codepoint2name
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
def xmlcharnamereplace(exc):
|
|
|
|
if not isinstance(exc, UnicodeEncodeError):
|
|
|
|
raise TypeError("don't know how to handle %r" % exc)
|
|
|
|
l = []
|
|
|
|
for c in exc.object[exc.start:exc.end]:
|
|
|
|
if ord(c) in codepoint2name:
|
2007-05-02 16:09:54 -03:00
|
|
|
l.append("&%s;" % codepoint2name[ord(c)])
|
2006-04-21 07:40:58 -03:00
|
|
|
else:
|
2007-05-02 16:09:54 -03:00
|
|
|
l.append("&#%d;" % ord(c))
|
|
|
|
return ("".join(l), exc.end)
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
codecs.register_error("test.xmlcharnamereplace", xmlcharnamereplace)
|
2004-01-17 10:29:29 -04:00
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
if self.xmlcharnametest:
|
|
|
|
sin, sout = self.xmlcharnametest
|
|
|
|
else:
|
2007-05-02 16:09:54 -03:00
|
|
|
sin = "\xab\u211c\xbb = \u2329\u1234\u232a"
|
2007-05-17 20:59:11 -03:00
|
|
|
sout = b"«ℜ» = ⟨ሴ⟩"
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(self.encode(sin,
|
|
|
|
"test.xmlcharnamereplace")[0], sout)
|
|
|
|
|
2012-12-02 14:04:37 -04:00
|
|
|
def test_callback_returns_bytes(self):
|
|
|
|
def myreplace(exc):
|
|
|
|
return (b"1234", exc.end)
|
|
|
|
codecs.register_error("test.cjktest", myreplace)
|
|
|
|
enc = self.encode("abc" + self.unmappedunicode + "def", "test.cjktest")[0]
|
|
|
|
self.assertEqual(enc, b"abc1234def")
|
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
def test_callback_wrong_objects(self):
|
|
|
|
def myreplace(exc):
|
|
|
|
return (ret, exc.end)
|
|
|
|
codecs.register_error("test.cjktest", myreplace)
|
|
|
|
|
2012-12-02 13:37:04 -04:00
|
|
|
for ret in ([1, 2, 3], [], None, object()):
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertRaises(TypeError, self.encode, self.unmappedunicode,
|
|
|
|
'test.cjktest')
|
|
|
|
|
|
|
|
def test_callback_long_index(self):
|
|
|
|
def myreplace(exc):
|
2007-05-02 16:09:54 -03:00
|
|
|
return ('x', int(exc.end))
|
2006-04-21 07:40:58 -03:00
|
|
|
codecs.register_error("test.cjktest", myreplace)
|
2007-05-02 16:09:54 -03:00
|
|
|
self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
|
2007-05-17 20:59:11 -03:00
|
|
|
'test.cjktest'), (b'abcdxefgh', 9))
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
def myreplace(exc):
|
2007-12-04 19:02:19 -04:00
|
|
|
return ('x', sys.maxsize + 1)
|
2006-04-21 07:40:58 -03:00
|
|
|
codecs.register_error("test.cjktest", myreplace)
|
|
|
|
self.assertRaises(IndexError, self.encode, self.unmappedunicode,
|
|
|
|
'test.cjktest')
|
|
|
|
|
|
|
|
def test_callback_None_index(self):
|
|
|
|
def myreplace(exc):
|
2007-05-02 16:09:54 -03:00
|
|
|
return ('x', None)
|
2006-04-21 07:40:58 -03:00
|
|
|
codecs.register_error("test.cjktest", myreplace)
|
|
|
|
self.assertRaises(TypeError, self.encode, self.unmappedunicode,
|
|
|
|
'test.cjktest')
|
|
|
|
|
|
|
|
def test_callback_backward_index(self):
|
|
|
|
def myreplace(exc):
|
|
|
|
if myreplace.limit > 0:
|
|
|
|
myreplace.limit -= 1
|
2007-05-02 16:09:54 -03:00
|
|
|
return ('REPLACED', 0)
|
2006-04-21 07:40:58 -03:00
|
|
|
else:
|
2007-05-02 16:09:54 -03:00
|
|
|
return ('TERMINAL', exc.end)
|
2006-04-21 07:40:58 -03:00
|
|
|
myreplace.limit = 3
|
|
|
|
codecs.register_error("test.cjktest", myreplace)
|
2007-05-02 16:09:54 -03:00
|
|
|
self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
|
2006-04-21 07:40:58 -03:00
|
|
|
'test.cjktest'),
|
2007-05-17 20:59:11 -03:00
|
|
|
(b'abcdREPLACEDabcdREPLACEDabcdREPLACEDabcdTERMINALefgh', 9))
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
def test_callback_forward_index(self):
|
|
|
|
def myreplace(exc):
|
2007-05-02 16:09:54 -03:00
|
|
|
return ('REPLACED', exc.end + 2)
|
2006-04-21 07:40:58 -03:00
|
|
|
codecs.register_error("test.cjktest", myreplace)
|
2007-05-02 16:09:54 -03:00
|
|
|
self.assertEqual(self.encode('abcd' + self.unmappedunicode + 'efgh',
|
2007-05-17 20:59:11 -03:00
|
|
|
'test.cjktest'), (b'abcdREPLACEDgh', 9))
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
def test_callback_index_outofbound(self):
|
|
|
|
def myreplace(exc):
|
2007-05-02 16:09:54 -03:00
|
|
|
return ('TERM', 100)
|
2006-04-21 07:40:58 -03:00
|
|
|
codecs.register_error("test.cjktest", myreplace)
|
|
|
|
self.assertRaises(IndexError, self.encode, self.unmappedunicode,
|
|
|
|
'test.cjktest')
|
|
|
|
|
|
|
|
def test_incrementalencoder(self):
|
|
|
|
UTF8Reader = codecs.getreader('utf-8')
|
2007-05-07 19:24:25 -03:00
|
|
|
for sizehint in [None] + list(range(1, 33)) + \
|
2006-04-21 07:40:58 -03:00
|
|
|
[64, 128, 256, 512, 1024]:
|
2007-05-17 20:59:11 -03:00
|
|
|
istream = UTF8Reader(BytesIO(self.tstring[1]))
|
|
|
|
ostream = BytesIO()
|
2006-04-21 07:40:58 -03:00
|
|
|
encoder = self.incrementalencoder()
|
|
|
|
while 1:
|
|
|
|
if sizehint is not None:
|
|
|
|
data = istream.read(sizehint)
|
|
|
|
else:
|
|
|
|
data = istream.read()
|
2004-01-17 10:29:29 -04:00
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
if not data:
|
|
|
|
break
|
|
|
|
e = encoder.encode(data)
|
|
|
|
ostream.write(e)
|
2004-01-17 10:29:29 -04:00
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
self.assertEqual(ostream.getvalue(), self.tstring[0])
|
2004-01-17 10:29:29 -04:00
|
|
|
|
2006-04-21 07:40:58 -03:00
|
|
|
def test_incrementaldecoder(self):
|
|
|
|
UTF8Writer = codecs.getwriter('utf-8')
|
2007-05-07 19:24:25 -03:00
|
|
|
for sizehint in [None, -1] + list(range(1, 33)) + \
|
2006-04-21 07:40:58 -03:00
|
|
|
[64, 128, 256, 512, 1024]:
|
2007-05-17 20:59:11 -03:00
|
|
|
istream = BytesIO(self.tstring[0])
|
|
|
|
ostream = UTF8Writer(BytesIO())
|
2006-04-21 07:40:58 -03:00
|
|
|
decoder = self.incrementaldecoder()
|
|
|
|
while 1:
|
|
|
|
data = istream.read(sizehint)
|
|
|
|
if not data:
|
|
|
|
break
|
2004-01-17 10:29:29 -04:00
|
|
|
else:
|
2006-04-21 07:40:58 -03:00
|
|
|
u = decoder.decode(data)
|
|
|
|
ostream.write(u)
|
|
|
|
|
|
|
|
self.assertEqual(ostream.getvalue(), self.tstring[1])
|
|
|
|
|
|
|
|
def test_incrementalencoder_error_callback(self):
|
|
|
|
inv = self.unmappedunicode
|
|
|
|
|
|
|
|
e = self.incrementalencoder()
|
|
|
|
self.assertRaises(UnicodeEncodeError, e.encode, inv, True)
|
|
|
|
|
|
|
|
e.errors = 'ignore'
|
2007-05-17 20:59:11 -03:00
|
|
|
self.assertEqual(e.encode(inv, True), b'')
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
e.reset()
|
|
|
|
def tempreplace(exc):
|
2007-05-02 16:09:54 -03:00
|
|
|
return ('called', exc.end)
|
2006-04-21 07:40:58 -03:00
|
|
|
codecs.register_error('test.incremental_error_callback', tempreplace)
|
|
|
|
e.errors = 'test.incremental_error_callback'
|
2007-05-17 20:59:11 -03:00
|
|
|
self.assertEqual(e.encode(inv, True), b'called')
|
2006-04-21 07:40:58 -03:00
|
|
|
|
|
|
|
# again
|
|
|
|
e.errors = 'ignore'
|
2007-05-17 20:59:11 -03:00
|
|
|
self.assertEqual(e.encode(inv, True), b'')
|
2004-01-17 10:29:29 -04:00
|
|
|
|
|
|
|
def test_streamreader(self):
|
|
|
|
UTF8Writer = codecs.getwriter('utf-8')
|
|
|
|
for name in ["read", "readline", "readlines"]:
|
2007-05-07 19:24:25 -03:00
|
|
|
for sizehint in [None, -1] + list(range(1, 33)) + \
|
2004-01-17 10:29:29 -04:00
|
|
|
[64, 128, 256, 512, 1024]:
|
2007-05-17 20:59:11 -03:00
|
|
|
istream = self.reader(BytesIO(self.tstring[0]))
|
|
|
|
ostream = UTF8Writer(BytesIO())
|
2004-01-17 10:29:29 -04:00
|
|
|
func = getattr(istream, name)
|
|
|
|
while 1:
|
|
|
|
data = func(sizehint)
|
|
|
|
if not data:
|
|
|
|
break
|
|
|
|
if name == "readlines":
|
|
|
|
ostream.writelines(data)
|
|
|
|
else:
|
|
|
|
ostream.write(data)
|
|
|
|
|
|
|
|
self.assertEqual(ostream.getvalue(), self.tstring[1])
|
|
|
|
|
|
|
|
def test_streamwriter(self):
|
2006-04-21 07:40:58 -03:00
|
|
|
readfuncs = ('read', 'readline', 'readlines')
|
2004-01-17 10:29:29 -04:00
|
|
|
UTF8Reader = codecs.getreader('utf-8')
|
|
|
|
for name in readfuncs:
|
2007-05-07 19:24:25 -03:00
|
|
|
for sizehint in [None] + list(range(1, 33)) + \
|
2004-01-17 10:29:29 -04:00
|
|
|
[64, 128, 256, 512, 1024]:
|
2007-05-17 20:59:11 -03:00
|
|
|
istream = UTF8Reader(BytesIO(self.tstring[1]))
|
|
|
|
ostream = self.writer(BytesIO())
|
2004-01-17 10:29:29 -04:00
|
|
|
func = getattr(istream, name)
|
|
|
|
while 1:
|
|
|
|
if sizehint is not None:
|
|
|
|
data = func(sizehint)
|
|
|
|
else:
|
|
|
|
data = func()
|
|
|
|
|
|
|
|
if not data:
|
|
|
|
break
|
|
|
|
if name == "readlines":
|
|
|
|
ostream.writelines(data)
|
|
|
|
else:
|
|
|
|
ostream.write(data)
|
|
|
|
|
|
|
|
self.assertEqual(ostream.getvalue(), self.tstring[0])
|
|
|
|
|
2015-07-16 17:17:31 -03:00
|
|
|
def test_streamwriter_reset_no_pending(self):
|
|
|
|
# Issue #23247: Calling reset() on a fresh StreamWriter instance
|
|
|
|
# (without pending data) must not crash
|
|
|
|
stream = BytesIO()
|
|
|
|
writer = self.writer(stream)
|
|
|
|
writer.reset()
|
|
|
|
|
2018-12-17 10:52:45 -04:00
|
|
|
def test_incrementalencoder_del_segfault(self):
|
|
|
|
e = self.incrementalencoder()
|
|
|
|
with self.assertRaises(AttributeError):
|
|
|
|
del e.errors
|
|
|
|
|
2004-01-17 10:29:29 -04:00
|
|
|
|
|
|
|
class TestBase_Mapping(unittest.TestCase):
|
|
|
|
pass_enctest = []
|
|
|
|
pass_dectest = []
|
|
|
|
supmaps = []
|
2011-06-03 18:44:39 -03:00
|
|
|
codectests = []
|
2004-01-17 10:29:29 -04:00
|
|
|
|
2014-07-01 21:55:04 -03:00
|
|
|
def setUp(self):
|
2008-03-08 07:59:08 -04:00
|
|
|
try:
|
2010-10-14 19:11:44 -03:00
|
|
|
self.open_mapping_file().close() # test it to report the error early
|
2012-12-25 10:47:37 -04:00
|
|
|
except (OSError, HTTPException):
|
2009-11-01 11:59:11 -04:00
|
|
|
self.skipTest("Could not retrieve "+self.mapfileurl)
|
2005-12-10 13:44:27 -04:00
|
|
|
|
|
|
|
def open_mapping_file(self):
|
2008-05-20 18:35:26 -03:00
|
|
|
return support.open_urlresource(self.mapfileurl)
|
2004-01-17 10:29:29 -04:00
|
|
|
|
|
|
|
def test_mapping_file(self):
|
Merged revisions 56753-56781 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56760 | neal.norwitz | 2007-08-05 18:55:39 -0700 (Sun, 05 Aug 2007) | 178 lines
Merged revisions 56477-56759 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56485 | facundo.batista | 2007-07-21 17:13:00 -0700 (Sat, 21 Jul 2007) | 5 lines
Selectively enable tests for asyncore.readwrite based on the presence
of poll support in the select module (since this is the only case in
which readwrite can be called). [GSoC - Alan McIntyre]
........
r56488 | nick.coghlan | 2007-07-22 03:18:07 -0700 (Sun, 22 Jul 2007) | 1 line
Add explicit relative import tests for runpy.run_module
........
r56509 | nick.coghlan | 2007-07-23 06:41:45 -0700 (Mon, 23 Jul 2007) | 5 lines
Correctly cleanup sys.modules after executing runpy relative import
tests
Restore Python 2.4 ImportError when attempting to execute a package
(as imports cannot be guaranteed to work properly if you try it)
........
r56519 | nick.coghlan | 2007-07-24 06:07:38 -0700 (Tue, 24 Jul 2007) | 1 line
Tweak runpy test to do a better job of confirming that sys has been manipulated correctly
........
r56520 | nick.coghlan | 2007-07-24 06:58:28 -0700 (Tue, 24 Jul 2007) | 1 line
Fix an incompatibility between the -i and -m command line switches as reported on python-dev by PJE - runpy.run_module now leaves any changes it makes to the sys module intact after the function terminates
........
r56523 | nick.coghlan | 2007-07-24 07:39:23 -0700 (Tue, 24 Jul 2007) | 1 line
Try to get rid of spurious failure in test_resource on the Debian buildbots by changing the file size limit before attempting to close the file
........
r56533 | facundo.batista | 2007-07-24 14:20:42 -0700 (Tue, 24 Jul 2007) | 7 lines
New tests for basic behavior of smtplib.SMTP and
smtpd.DebuggingServer. Change to use global host & port number
variables. Modified the 'server' to take a string to send back in
order to vary test server responses. Added a test for the reaction of
smtplib.SMTP to a non-200 HELO response. [GSoC - Alan McIntyre]
........
r56538 | nick.coghlan | 2007-07-25 05:57:48 -0700 (Wed, 25 Jul 2007) | 1 line
More buildbot cleanup - let the OS assign the port for test_urllib2_localnet
........
r56539 | nick.coghlan | 2007-07-25 06:18:58 -0700 (Wed, 25 Jul 2007) | 1 line
Add a temporary diagnostic message before a strange failure on the alpha Debian buildbot
........
r56543 | martin.v.loewis | 2007-07-25 09:24:23 -0700 (Wed, 25 Jul 2007) | 2 lines
Change location of the package index to pypi.python.org/pypi
........
r56551 | georg.brandl | 2007-07-26 02:36:25 -0700 (Thu, 26 Jul 2007) | 2 lines
tabs, newlines and crs are valid XML characters.
........
r56553 | nick.coghlan | 2007-07-26 07:03:00 -0700 (Thu, 26 Jul 2007) | 1 line
Add explicit test for a misbehaving math.floor
........
r56561 | mark.hammond | 2007-07-26 21:52:32 -0700 (Thu, 26 Jul 2007) | 3 lines
In consultation with Kristjan Jonsson, only define WINVER and _WINNT_WIN32
if (a) we are building Python itself and (b) no one previously defined them
........
r56562 | mark.hammond | 2007-07-26 22:08:54 -0700 (Thu, 26 Jul 2007) | 2 lines
Correctly detect AMD64 architecture on VC2003
........
r56566 | nick.coghlan | 2007-07-27 03:36:30 -0700 (Fri, 27 Jul 2007) | 1 line
Make test_math error messages more meaningful for small discrepancies in results
........
r56588 | martin.v.loewis | 2007-07-27 11:28:22 -0700 (Fri, 27 Jul 2007) | 2 lines
Bug #978833: Close https sockets by releasing the _ssl object.
........
r56601 | martin.v.loewis | 2007-07-28 00:03:05 -0700 (Sat, 28 Jul 2007) | 3 lines
Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
represent the result in a single character.
........
r56604 | facundo.batista | 2007-07-28 07:21:22 -0700 (Sat, 28 Jul 2007) | 9 lines
Moved all of the capture_server socket setup code into the try block
so that the event gets set if a failure occurs during server setup
(otherwise the test will block forever). Changed to let the OS assign
the server port number, and client side of test waits for port number
assignment before proceeding. The test data in DispatcherWithSendTests
is also sent in multiple send() calls instead of one to make sure this
works properly. [GSoC - Alan McIntyre]
........
r56611 | georg.brandl | 2007-07-29 01:26:10 -0700 (Sun, 29 Jul 2007) | 2 lines
Clarify PEP 343 description.
........
r56614 | georg.brandl | 2007-07-29 02:11:15 -0700 (Sun, 29 Jul 2007) | 2 lines
try-except-finally is new in 2.5.
........
r56617 | facundo.batista | 2007-07-29 07:23:08 -0700 (Sun, 29 Jul 2007) | 9 lines
Added tests for asynchat classes simple_producer & fifo, and the
find_prefix_at_end function. Check behavior of a string given as a
producer. Added tests for behavior of asynchat.async_chat when given
int, long, and None terminator arguments. Added usepoll attribute to
TestAsynchat to allow running the asynchat tests with poll support
chosen whether it's available or not (improves coverage of asyncore
code). [GSoC - Alan McIntyre]
........
r56620 | georg.brandl | 2007-07-29 10:38:35 -0700 (Sun, 29 Jul 2007) | 2 lines
Bug #1763149: use proper slice syntax in docstring.
(backport)
........
r56624 | mark.hammond | 2007-07-29 17:45:29 -0700 (Sun, 29 Jul 2007) | 4 lines
Correct use of Py_BUILD_CORE - now make sure it is defined before it is
referenced, and also fix definition of _WIN32_WINNT.
Resolves patch 1761803.
........
r56632 | facundo.batista | 2007-07-30 20:03:34 -0700 (Mon, 30 Jul 2007) | 8 lines
When running asynchat tests on OS X (darwin), the test client now
overrides asyncore.dispatcher.handle_expt to do nothing, since
select.poll gives a POLLHUP error at the completion of these tests.
Added timeout & count arguments to several asyncore.loop calls to
avoid the possibility of a test hanging up a build. [GSoC - Alan
McIntyre]
........
r56633 | nick.coghlan | 2007-07-31 06:38:01 -0700 (Tue, 31 Jul 2007) | 1 line
Eliminate RLock race condition reported in SF bug #1764059
........
r56636 | martin.v.loewis | 2007-07-31 12:57:56 -0700 (Tue, 31 Jul 2007) | 2 lines
Define _BSD_SOURCE, to get access to POSIX extensions on OpenBSD 4.1+.
........
r56653 | facundo.batista | 2007-08-01 16:18:36 -0700 (Wed, 01 Aug 2007) | 9 lines
Allow the OS to select a free port for each test server. For
DebuggingServerTests, construct SMTP objects with a localhost argument
to avoid abysmally long FQDN lookups (not relevant to items under
test) on some machines that would cause the test to fail. Moved server
setup code in the server function inside the try block to avoid the
possibility of setup failure hanging the test. Minor edits to conform
to PEP 8. [GSoC - Alan McIntyre]
........
r56681 | matthias.klose | 2007-08-02 14:33:13 -0700 (Thu, 02 Aug 2007) | 2 lines
- Allow Emacs 22 for building the documentation in info format.
........
r56689 | neal.norwitz | 2007-08-02 23:46:29 -0700 (Thu, 02 Aug 2007) | 1 line
Py_ssize_t is defined regardless of HAVE_LONG_LONG. Will backport
........
r56727 | hyeshik.chang | 2007-08-03 21:10:18 -0700 (Fri, 03 Aug 2007) | 3 lines
Fix gb18030 codec's bug that doesn't map two-byte characters on
GB18030 extension in encoding. (bug reported by Bjorn Stabell)
........
r56751 | neal.norwitz | 2007-08-04 20:23:31 -0700 (Sat, 04 Aug 2007) | 7 lines
Handle errors when generating a warning.
The value is always written to the returned pointer if getting it was
successful, even if a warning causes an error. (This probably doesn't matter
as the caller will probably discard the value.)
Will backport.
........
................
2007-08-06 20:33:07 -03:00
|
|
|
if self.mapfileurl.endswith('.xml'):
|
|
|
|
self._test_mapping_file_ucm()
|
|
|
|
else:
|
|
|
|
self._test_mapping_file_plain()
|
|
|
|
|
|
|
|
def _test_mapping_file_plain(self):
|
2020-10-06 09:14:51 -03:00
|
|
|
def unichrs(s):
|
|
|
|
return ''.join(chr(int(x, 16)) for x in s.split('+'))
|
|
|
|
|
2004-01-17 10:29:29 -04:00
|
|
|
urt_wa = {}
|
|
|
|
|
2010-10-14 19:11:44 -03:00
|
|
|
with self.open_mapping_file() as f:
|
|
|
|
for line in f:
|
|
|
|
if not line:
|
|
|
|
break
|
2020-10-06 09:14:51 -03:00
|
|
|
data = line.split('#')[0].split()
|
2010-10-14 19:11:44 -03:00
|
|
|
if len(data) != 2:
|
|
|
|
continue
|
|
|
|
|
2020-10-06 09:14:51 -03:00
|
|
|
if data[0][:2] != '0x':
|
|
|
|
self.fail(f"Invalid line: {line!r}")
|
|
|
|
csetch = bytes.fromhex(data[0][2:])
|
|
|
|
if len(csetch) == 1 and 0x80 <= csetch[0]:
|
2010-10-14 19:11:44 -03:00
|
|
|
continue
|
2004-01-17 10:29:29 -04:00
|
|
|
|
2010-10-14 19:11:44 -03:00
|
|
|
unich = unichrs(data[1])
|
|
|
|
if ord(unich) == 0xfffd or unich in urt_wa:
|
|
|
|
continue
|
|
|
|
urt_wa[unich] = csetch
|
2004-01-17 10:29:29 -04:00
|
|
|
|
2010-10-14 19:11:44 -03:00
|
|
|
self._testpoint(csetch, unich)
|
2004-01-17 10:29:29 -04:00
|
|
|
|
Merged revisions 56753-56781 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56760 | neal.norwitz | 2007-08-05 18:55:39 -0700 (Sun, 05 Aug 2007) | 178 lines
Merged revisions 56477-56759 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56485 | facundo.batista | 2007-07-21 17:13:00 -0700 (Sat, 21 Jul 2007) | 5 lines
Selectively enable tests for asyncore.readwrite based on the presence
of poll support in the select module (since this is the only case in
which readwrite can be called). [GSoC - Alan McIntyre]
........
r56488 | nick.coghlan | 2007-07-22 03:18:07 -0700 (Sun, 22 Jul 2007) | 1 line
Add explicit relative import tests for runpy.run_module
........
r56509 | nick.coghlan | 2007-07-23 06:41:45 -0700 (Mon, 23 Jul 2007) | 5 lines
Correctly cleanup sys.modules after executing runpy relative import
tests
Restore Python 2.4 ImportError when attempting to execute a package
(as imports cannot be guaranteed to work properly if you try it)
........
r56519 | nick.coghlan | 2007-07-24 06:07:38 -0700 (Tue, 24 Jul 2007) | 1 line
Tweak runpy test to do a better job of confirming that sys has been manipulated correctly
........
r56520 | nick.coghlan | 2007-07-24 06:58:28 -0700 (Tue, 24 Jul 2007) | 1 line
Fix an incompatibility between the -i and -m command line switches as reported on python-dev by PJE - runpy.run_module now leaves any changes it makes to the sys module intact after the function terminates
........
r56523 | nick.coghlan | 2007-07-24 07:39:23 -0700 (Tue, 24 Jul 2007) | 1 line
Try to get rid of spurious failure in test_resource on the Debian buildbots by changing the file size limit before attempting to close the file
........
r56533 | facundo.batista | 2007-07-24 14:20:42 -0700 (Tue, 24 Jul 2007) | 7 lines
New tests for basic behavior of smtplib.SMTP and
smtpd.DebuggingServer. Change to use global host & port number
variables. Modified the 'server' to take a string to send back in
order to vary test server responses. Added a test for the reaction of
smtplib.SMTP to a non-200 HELO response. [GSoC - Alan McIntyre]
........
r56538 | nick.coghlan | 2007-07-25 05:57:48 -0700 (Wed, 25 Jul 2007) | 1 line
More buildbot cleanup - let the OS assign the port for test_urllib2_localnet
........
r56539 | nick.coghlan | 2007-07-25 06:18:58 -0700 (Wed, 25 Jul 2007) | 1 line
Add a temporary diagnostic message before a strange failure on the alpha Debian buildbot
........
r56543 | martin.v.loewis | 2007-07-25 09:24:23 -0700 (Wed, 25 Jul 2007) | 2 lines
Change location of the package index to pypi.python.org/pypi
........
r56551 | georg.brandl | 2007-07-26 02:36:25 -0700 (Thu, 26 Jul 2007) | 2 lines
tabs, newlines and crs are valid XML characters.
........
r56553 | nick.coghlan | 2007-07-26 07:03:00 -0700 (Thu, 26 Jul 2007) | 1 line
Add explicit test for a misbehaving math.floor
........
r56561 | mark.hammond | 2007-07-26 21:52:32 -0700 (Thu, 26 Jul 2007) | 3 lines
In consultation with Kristjan Jonsson, only define WINVER and _WINNT_WIN32
if (a) we are building Python itself and (b) no one previously defined them
........
r56562 | mark.hammond | 2007-07-26 22:08:54 -0700 (Thu, 26 Jul 2007) | 2 lines
Correctly detect AMD64 architecture on VC2003
........
r56566 | nick.coghlan | 2007-07-27 03:36:30 -0700 (Fri, 27 Jul 2007) | 1 line
Make test_math error messages more meaningful for small discrepancies in results
........
r56588 | martin.v.loewis | 2007-07-27 11:28:22 -0700 (Fri, 27 Jul 2007) | 2 lines
Bug #978833: Close https sockets by releasing the _ssl object.
........
r56601 | martin.v.loewis | 2007-07-28 00:03:05 -0700 (Sat, 28 Jul 2007) | 3 lines
Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
represent the result in a single character.
........
r56604 | facundo.batista | 2007-07-28 07:21:22 -0700 (Sat, 28 Jul 2007) | 9 lines
Moved all of the capture_server socket setup code into the try block
so that the event gets set if a failure occurs during server setup
(otherwise the test will block forever). Changed to let the OS assign
the server port number, and client side of test waits for port number
assignment before proceeding. The test data in DispatcherWithSendTests
is also sent in multiple send() calls instead of one to make sure this
works properly. [GSoC - Alan McIntyre]
........
r56611 | georg.brandl | 2007-07-29 01:26:10 -0700 (Sun, 29 Jul 2007) | 2 lines
Clarify PEP 343 description.
........
r56614 | georg.brandl | 2007-07-29 02:11:15 -0700 (Sun, 29 Jul 2007) | 2 lines
try-except-finally is new in 2.5.
........
r56617 | facundo.batista | 2007-07-29 07:23:08 -0700 (Sun, 29 Jul 2007) | 9 lines
Added tests for asynchat classes simple_producer & fifo, and the
find_prefix_at_end function. Check behavior of a string given as a
producer. Added tests for behavior of asynchat.async_chat when given
int, long, and None terminator arguments. Added usepoll attribute to
TestAsynchat to allow running the asynchat tests with poll support
chosen whether it's available or not (improves coverage of asyncore
code). [GSoC - Alan McIntyre]
........
r56620 | georg.brandl | 2007-07-29 10:38:35 -0700 (Sun, 29 Jul 2007) | 2 lines
Bug #1763149: use proper slice syntax in docstring.
(backport)
........
r56624 | mark.hammond | 2007-07-29 17:45:29 -0700 (Sun, 29 Jul 2007) | 4 lines
Correct use of Py_BUILD_CORE - now make sure it is defined before it is
referenced, and also fix definition of _WIN32_WINNT.
Resolves patch 1761803.
........
r56632 | facundo.batista | 2007-07-30 20:03:34 -0700 (Mon, 30 Jul 2007) | 8 lines
When running asynchat tests on OS X (darwin), the test client now
overrides asyncore.dispatcher.handle_expt to do nothing, since
select.poll gives a POLLHUP error at the completion of these tests.
Added timeout & count arguments to several asyncore.loop calls to
avoid the possibility of a test hanging up a build. [GSoC - Alan
McIntyre]
........
r56633 | nick.coghlan | 2007-07-31 06:38:01 -0700 (Tue, 31 Jul 2007) | 1 line
Eliminate RLock race condition reported in SF bug #1764059
........
r56636 | martin.v.loewis | 2007-07-31 12:57:56 -0700 (Tue, 31 Jul 2007) | 2 lines
Define _BSD_SOURCE, to get access to POSIX extensions on OpenBSD 4.1+.
........
r56653 | facundo.batista | 2007-08-01 16:18:36 -0700 (Wed, 01 Aug 2007) | 9 lines
Allow the OS to select a free port for each test server. For
DebuggingServerTests, construct SMTP objects with a localhost argument
to avoid abysmally long FQDN lookups (not relevant to items under
test) on some machines that would cause the test to fail. Moved server
setup code in the server function inside the try block to avoid the
possibility of setup failure hanging the test. Minor edits to conform
to PEP 8. [GSoC - Alan McIntyre]
........
r56681 | matthias.klose | 2007-08-02 14:33:13 -0700 (Thu, 02 Aug 2007) | 2 lines
- Allow Emacs 22 for building the documentation in info format.
........
r56689 | neal.norwitz | 2007-08-02 23:46:29 -0700 (Thu, 02 Aug 2007) | 1 line
Py_ssize_t is defined regardless of HAVE_LONG_LONG. Will backport
........
r56727 | hyeshik.chang | 2007-08-03 21:10:18 -0700 (Fri, 03 Aug 2007) | 3 lines
Fix gb18030 codec's bug that doesn't map two-byte characters on
GB18030 extension in encoding. (bug reported by Bjorn Stabell)
........
r56751 | neal.norwitz | 2007-08-04 20:23:31 -0700 (Sat, 04 Aug 2007) | 7 lines
Handle errors when generating a warning.
The value is always written to the returned pointer if getting it was
successful, even if a warning causes an error. (This probably doesn't matter
as the caller will probably discard the value.)
Will backport.
........
................
2007-08-06 20:33:07 -03:00
|
|
|
def _test_mapping_file_ucm(self):
|
2010-10-14 19:11:44 -03:00
|
|
|
with self.open_mapping_file() as f:
|
|
|
|
ucmdata = f.read()
|
Merged revisions 56753-56781 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56760 | neal.norwitz | 2007-08-05 18:55:39 -0700 (Sun, 05 Aug 2007) | 178 lines
Merged revisions 56477-56759 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56485 | facundo.batista | 2007-07-21 17:13:00 -0700 (Sat, 21 Jul 2007) | 5 lines
Selectively enable tests for asyncore.readwrite based on the presence
of poll support in the select module (since this is the only case in
which readwrite can be called). [GSoC - Alan McIntyre]
........
r56488 | nick.coghlan | 2007-07-22 03:18:07 -0700 (Sun, 22 Jul 2007) | 1 line
Add explicit relative import tests for runpy.run_module
........
r56509 | nick.coghlan | 2007-07-23 06:41:45 -0700 (Mon, 23 Jul 2007) | 5 lines
Correctly cleanup sys.modules after executing runpy relative import
tests
Restore Python 2.4 ImportError when attempting to execute a package
(as imports cannot be guaranteed to work properly if you try it)
........
r56519 | nick.coghlan | 2007-07-24 06:07:38 -0700 (Tue, 24 Jul 2007) | 1 line
Tweak runpy test to do a better job of confirming that sys has been manipulated correctly
........
r56520 | nick.coghlan | 2007-07-24 06:58:28 -0700 (Tue, 24 Jul 2007) | 1 line
Fix an incompatibility between the -i and -m command line switches as reported on python-dev by PJE - runpy.run_module now leaves any changes it makes to the sys module intact after the function terminates
........
r56523 | nick.coghlan | 2007-07-24 07:39:23 -0700 (Tue, 24 Jul 2007) | 1 line
Try to get rid of spurious failure in test_resource on the Debian buildbots by changing the file size limit before attempting to close the file
........
r56533 | facundo.batista | 2007-07-24 14:20:42 -0700 (Tue, 24 Jul 2007) | 7 lines
New tests for basic behavior of smtplib.SMTP and
smtpd.DebuggingServer. Change to use global host & port number
variables. Modified the 'server' to take a string to send back in
order to vary test server responses. Added a test for the reaction of
smtplib.SMTP to a non-200 HELO response. [GSoC - Alan McIntyre]
........
r56538 | nick.coghlan | 2007-07-25 05:57:48 -0700 (Wed, 25 Jul 2007) | 1 line
More buildbot cleanup - let the OS assign the port for test_urllib2_localnet
........
r56539 | nick.coghlan | 2007-07-25 06:18:58 -0700 (Wed, 25 Jul 2007) | 1 line
Add a temporary diagnostic message before a strange failure on the alpha Debian buildbot
........
r56543 | martin.v.loewis | 2007-07-25 09:24:23 -0700 (Wed, 25 Jul 2007) | 2 lines
Change location of the package index to pypi.python.org/pypi
........
r56551 | georg.brandl | 2007-07-26 02:36:25 -0700 (Thu, 26 Jul 2007) | 2 lines
tabs, newlines and crs are valid XML characters.
........
r56553 | nick.coghlan | 2007-07-26 07:03:00 -0700 (Thu, 26 Jul 2007) | 1 line
Add explicit test for a misbehaving math.floor
........
r56561 | mark.hammond | 2007-07-26 21:52:32 -0700 (Thu, 26 Jul 2007) | 3 lines
In consultation with Kristjan Jonsson, only define WINVER and _WINNT_WIN32
if (a) we are building Python itself and (b) no one previously defined them
........
r56562 | mark.hammond | 2007-07-26 22:08:54 -0700 (Thu, 26 Jul 2007) | 2 lines
Correctly detect AMD64 architecture on VC2003
........
r56566 | nick.coghlan | 2007-07-27 03:36:30 -0700 (Fri, 27 Jul 2007) | 1 line
Make test_math error messages more meaningful for small discrepancies in results
........
r56588 | martin.v.loewis | 2007-07-27 11:28:22 -0700 (Fri, 27 Jul 2007) | 2 lines
Bug #978833: Close https sockets by releasing the _ssl object.
........
r56601 | martin.v.loewis | 2007-07-28 00:03:05 -0700 (Sat, 28 Jul 2007) | 3 lines
Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
represent the result in a single character.
........
r56604 | facundo.batista | 2007-07-28 07:21:22 -0700 (Sat, 28 Jul 2007) | 9 lines
Moved all of the capture_server socket setup code into the try block
so that the event gets set if a failure occurs during server setup
(otherwise the test will block forever). Changed to let the OS assign
the server port number, and client side of test waits for port number
assignment before proceeding. The test data in DispatcherWithSendTests
is also sent in multiple send() calls instead of one to make sure this
works properly. [GSoC - Alan McIntyre]
........
r56611 | georg.brandl | 2007-07-29 01:26:10 -0700 (Sun, 29 Jul 2007) | 2 lines
Clarify PEP 343 description.
........
r56614 | georg.brandl | 2007-07-29 02:11:15 -0700 (Sun, 29 Jul 2007) | 2 lines
try-except-finally is new in 2.5.
........
r56617 | facundo.batista | 2007-07-29 07:23:08 -0700 (Sun, 29 Jul 2007) | 9 lines
Added tests for asynchat classes simple_producer & fifo, and the
find_prefix_at_end function. Check behavior of a string given as a
producer. Added tests for behavior of asynchat.async_chat when given
int, long, and None terminator arguments. Added usepoll attribute to
TestAsynchat to allow running the asynchat tests with poll support
chosen whether it's available or not (improves coverage of asyncore
code). [GSoC - Alan McIntyre]
........
r56620 | georg.brandl | 2007-07-29 10:38:35 -0700 (Sun, 29 Jul 2007) | 2 lines
Bug #1763149: use proper slice syntax in docstring.
(backport)
........
r56624 | mark.hammond | 2007-07-29 17:45:29 -0700 (Sun, 29 Jul 2007) | 4 lines
Correct use of Py_BUILD_CORE - now make sure it is defined before it is
referenced, and also fix definition of _WIN32_WINNT.
Resolves patch 1761803.
........
r56632 | facundo.batista | 2007-07-30 20:03:34 -0700 (Mon, 30 Jul 2007) | 8 lines
When running asynchat tests on OS X (darwin), the test client now
overrides asyncore.dispatcher.handle_expt to do nothing, since
select.poll gives a POLLHUP error at the completion of these tests.
Added timeout & count arguments to several asyncore.loop calls to
avoid the possibility of a test hanging up a build. [GSoC - Alan
McIntyre]
........
r56633 | nick.coghlan | 2007-07-31 06:38:01 -0700 (Tue, 31 Jul 2007) | 1 line
Eliminate RLock race condition reported in SF bug #1764059
........
r56636 | martin.v.loewis | 2007-07-31 12:57:56 -0700 (Tue, 31 Jul 2007) | 2 lines
Define _BSD_SOURCE, to get access to POSIX extensions on OpenBSD 4.1+.
........
r56653 | facundo.batista | 2007-08-01 16:18:36 -0700 (Wed, 01 Aug 2007) | 9 lines
Allow the OS to select a free port for each test server. For
DebuggingServerTests, construct SMTP objects with a localhost argument
to avoid abysmally long FQDN lookups (not relevant to items under
test) on some machines that would cause the test to fail. Moved server
setup code in the server function inside the try block to avoid the
possibility of setup failure hanging the test. Minor edits to conform
to PEP 8. [GSoC - Alan McIntyre]
........
r56681 | matthias.klose | 2007-08-02 14:33:13 -0700 (Thu, 02 Aug 2007) | 2 lines
- Allow Emacs 22 for building the documentation in info format.
........
r56689 | neal.norwitz | 2007-08-02 23:46:29 -0700 (Thu, 02 Aug 2007) | 1 line
Py_ssize_t is defined regardless of HAVE_LONG_LONG. Will backport
........
r56727 | hyeshik.chang | 2007-08-03 21:10:18 -0700 (Fri, 03 Aug 2007) | 3 lines
Fix gb18030 codec's bug that doesn't map two-byte characters on
GB18030 extension in encoding. (bug reported by Bjorn Stabell)
........
r56751 | neal.norwitz | 2007-08-04 20:23:31 -0700 (Sat, 04 Aug 2007) | 7 lines
Handle errors when generating a warning.
The value is always written to the returned pointer if getting it was
successful, even if a warning causes an error. (This probably doesn't matter
as the caller will probably discard the value.)
Will backport.
........
................
2007-08-06 20:33:07 -03:00
|
|
|
uc = re.findall('<a u="([A-F0-9]{4})" b="([0-9A-F ]+)"/>', ucmdata)
|
|
|
|
for uni, coded in uc:
|
|
|
|
unich = chr(int(uni, 16))
|
2016-12-21 06:59:28 -04:00
|
|
|
codech = bytes.fromhex(coded)
|
Merged revisions 56753-56781 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/p3yk
................
r56760 | neal.norwitz | 2007-08-05 18:55:39 -0700 (Sun, 05 Aug 2007) | 178 lines
Merged revisions 56477-56759 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r56485 | facundo.batista | 2007-07-21 17:13:00 -0700 (Sat, 21 Jul 2007) | 5 lines
Selectively enable tests for asyncore.readwrite based on the presence
of poll support in the select module (since this is the only case in
which readwrite can be called). [GSoC - Alan McIntyre]
........
r56488 | nick.coghlan | 2007-07-22 03:18:07 -0700 (Sun, 22 Jul 2007) | 1 line
Add explicit relative import tests for runpy.run_module
........
r56509 | nick.coghlan | 2007-07-23 06:41:45 -0700 (Mon, 23 Jul 2007) | 5 lines
Correctly cleanup sys.modules after executing runpy relative import
tests
Restore Python 2.4 ImportError when attempting to execute a package
(as imports cannot be guaranteed to work properly if you try it)
........
r56519 | nick.coghlan | 2007-07-24 06:07:38 -0700 (Tue, 24 Jul 2007) | 1 line
Tweak runpy test to do a better job of confirming that sys has been manipulated correctly
........
r56520 | nick.coghlan | 2007-07-24 06:58:28 -0700 (Tue, 24 Jul 2007) | 1 line
Fix an incompatibility between the -i and -m command line switches as reported on python-dev by PJE - runpy.run_module now leaves any changes it makes to the sys module intact after the function terminates
........
r56523 | nick.coghlan | 2007-07-24 07:39:23 -0700 (Tue, 24 Jul 2007) | 1 line
Try to get rid of spurious failure in test_resource on the Debian buildbots by changing the file size limit before attempting to close the file
........
r56533 | facundo.batista | 2007-07-24 14:20:42 -0700 (Tue, 24 Jul 2007) | 7 lines
New tests for basic behavior of smtplib.SMTP and
smtpd.DebuggingServer. Change to use global host & port number
variables. Modified the 'server' to take a string to send back in
order to vary test server responses. Added a test for the reaction of
smtplib.SMTP to a non-200 HELO response. [GSoC - Alan McIntyre]
........
r56538 | nick.coghlan | 2007-07-25 05:57:48 -0700 (Wed, 25 Jul 2007) | 1 line
More buildbot cleanup - let the OS assign the port for test_urllib2_localnet
........
r56539 | nick.coghlan | 2007-07-25 06:18:58 -0700 (Wed, 25 Jul 2007) | 1 line
Add a temporary diagnostic message before a strange failure on the alpha Debian buildbot
........
r56543 | martin.v.loewis | 2007-07-25 09:24:23 -0700 (Wed, 25 Jul 2007) | 2 lines
Change location of the package index to pypi.python.org/pypi
........
r56551 | georg.brandl | 2007-07-26 02:36:25 -0700 (Thu, 26 Jul 2007) | 2 lines
tabs, newlines and crs are valid XML characters.
........
r56553 | nick.coghlan | 2007-07-26 07:03:00 -0700 (Thu, 26 Jul 2007) | 1 line
Add explicit test for a misbehaving math.floor
........
r56561 | mark.hammond | 2007-07-26 21:52:32 -0700 (Thu, 26 Jul 2007) | 3 lines
In consultation with Kristjan Jonsson, only define WINVER and _WINNT_WIN32
if (a) we are building Python itself and (b) no one previously defined them
........
r56562 | mark.hammond | 2007-07-26 22:08:54 -0700 (Thu, 26 Jul 2007) | 2 lines
Correctly detect AMD64 architecture on VC2003
........
r56566 | nick.coghlan | 2007-07-27 03:36:30 -0700 (Fri, 27 Jul 2007) | 1 line
Make test_math error messages more meaningful for small discrepancies in results
........
r56588 | martin.v.loewis | 2007-07-27 11:28:22 -0700 (Fri, 27 Jul 2007) | 2 lines
Bug #978833: Close https sockets by releasing the _ssl object.
........
r56601 | martin.v.loewis | 2007-07-28 00:03:05 -0700 (Sat, 28 Jul 2007) | 3 lines
Bug #1704793: Return UTF-16 pair if unicodedata.lookup cannot
represent the result in a single character.
........
r56604 | facundo.batista | 2007-07-28 07:21:22 -0700 (Sat, 28 Jul 2007) | 9 lines
Moved all of the capture_server socket setup code into the try block
so that the event gets set if a failure occurs during server setup
(otherwise the test will block forever). Changed to let the OS assign
the server port number, and client side of test waits for port number
assignment before proceeding. The test data in DispatcherWithSendTests
is also sent in multiple send() calls instead of one to make sure this
works properly. [GSoC - Alan McIntyre]
........
r56611 | georg.brandl | 2007-07-29 01:26:10 -0700 (Sun, 29 Jul 2007) | 2 lines
Clarify PEP 343 description.
........
r56614 | georg.brandl | 2007-07-29 02:11:15 -0700 (Sun, 29 Jul 2007) | 2 lines
try-except-finally is new in 2.5.
........
r56617 | facundo.batista | 2007-07-29 07:23:08 -0700 (Sun, 29 Jul 2007) | 9 lines
Added tests for asynchat classes simple_producer & fifo, and the
find_prefix_at_end function. Check behavior of a string given as a
producer. Added tests for behavior of asynchat.async_chat when given
int, long, and None terminator arguments. Added usepoll attribute to
TestAsynchat to allow running the asynchat tests with poll support
chosen whether it's available or not (improves coverage of asyncore
code). [GSoC - Alan McIntyre]
........
r56620 | georg.brandl | 2007-07-29 10:38:35 -0700 (Sun, 29 Jul 2007) | 2 lines
Bug #1763149: use proper slice syntax in docstring.
(backport)
........
r56624 | mark.hammond | 2007-07-29 17:45:29 -0700 (Sun, 29 Jul 2007) | 4 lines
Correct use of Py_BUILD_CORE - now make sure it is defined before it is
referenced, and also fix definition of _WIN32_WINNT.
Resolves patch 1761803.
........
r56632 | facundo.batista | 2007-07-30 20:03:34 -0700 (Mon, 30 Jul 2007) | 8 lines
When running asynchat tests on OS X (darwin), the test client now
overrides asyncore.dispatcher.handle_expt to do nothing, since
select.poll gives a POLLHUP error at the completion of these tests.
Added timeout & count arguments to several asyncore.loop calls to
avoid the possibility of a test hanging up a build. [GSoC - Alan
McIntyre]
........
r56633 | nick.coghlan | 2007-07-31 06:38:01 -0700 (Tue, 31 Jul 2007) | 1 line
Eliminate RLock race condition reported in SF bug #1764059
........
r56636 | martin.v.loewis | 2007-07-31 12:57:56 -0700 (Tue, 31 Jul 2007) | 2 lines
Define _BSD_SOURCE, to get access to POSIX extensions on OpenBSD 4.1+.
........
r56653 | facundo.batista | 2007-08-01 16:18:36 -0700 (Wed, 01 Aug 2007) | 9 lines
Allow the OS to select a free port for each test server. For
DebuggingServerTests, construct SMTP objects with a localhost argument
to avoid abysmally long FQDN lookups (not relevant to items under
test) on some machines that would cause the test to fail. Moved server
setup code in the server function inside the try block to avoid the
possibility of setup failure hanging the test. Minor edits to conform
to PEP 8. [GSoC - Alan McIntyre]
........
r56681 | matthias.klose | 2007-08-02 14:33:13 -0700 (Thu, 02 Aug 2007) | 2 lines
- Allow Emacs 22 for building the documentation in info format.
........
r56689 | neal.norwitz | 2007-08-02 23:46:29 -0700 (Thu, 02 Aug 2007) | 1 line
Py_ssize_t is defined regardless of HAVE_LONG_LONG. Will backport
........
r56727 | hyeshik.chang | 2007-08-03 21:10:18 -0700 (Fri, 03 Aug 2007) | 3 lines
Fix gb18030 codec's bug that doesn't map two-byte characters on
GB18030 extension in encoding. (bug reported by Bjorn Stabell)
........
r56751 | neal.norwitz | 2007-08-04 20:23:31 -0700 (Sat, 04 Aug 2007) | 7 lines
Handle errors when generating a warning.
The value is always written to the returned pointer if getting it was
successful, even if a warning causes an error. (This probably doesn't matter
as the caller will probably discard the value.)
Will backport.
........
................
2007-08-06 20:33:07 -03:00
|
|
|
self._testpoint(codech, unich)
|
|
|
|
|
2004-01-17 10:29:29 -04:00
|
|
|
def test_mapping_supplemental(self):
|
|
|
|
for mapping in self.supmaps:
|
|
|
|
self._testpoint(*mapping)
|
|
|
|
|
|
|
|
def _testpoint(self, csetch, unich):
|
|
|
|
if (csetch, unich) not in self.pass_enctest:
|
|
|
|
self.assertEqual(unich.encode(self.encoding), csetch)
|
|
|
|
if (csetch, unich) not in self.pass_dectest:
|
2007-05-02 16:09:54 -03:00
|
|
|
self.assertEqual(str(csetch, self.encoding), unich)
|
2004-01-17 10:29:29 -04:00
|
|
|
|
2011-06-03 18:44:39 -03:00
|
|
|
def test_errorhandle(self):
|
|
|
|
for source, scheme, expected in self.codectests:
|
|
|
|
if isinstance(source, bytes):
|
|
|
|
func = source.decode
|
|
|
|
else:
|
|
|
|
func = source.encode
|
|
|
|
if expected:
|
|
|
|
if isinstance(source, bytes):
|
|
|
|
result = func(self.encoding, scheme)
|
|
|
|
self.assertTrue(type(result) is str, type(result))
|
|
|
|
self.assertEqual(result, expected,
|
|
|
|
'%a.decode(%r, %r)=%a != %a'
|
|
|
|
% (source, self.encoding, scheme, result,
|
|
|
|
expected))
|
|
|
|
else:
|
|
|
|
result = func(self.encoding, scheme)
|
|
|
|
self.assertTrue(type(result) is bytes, type(result))
|
|
|
|
self.assertEqual(result, expected,
|
|
|
|
'%a.encode(%r, %r)=%a != %a'
|
|
|
|
% (source, self.encoding, scheme, result,
|
|
|
|
expected))
|
|
|
|
else:
|
|
|
|
self.assertRaises(UnicodeError, func, self.encoding, scheme)
|
|
|
|
|
2011-05-16 11:43:38 -03:00
|
|
|
def load_teststring(name):
|
|
|
|
dir = os.path.join(os.path.dirname(__file__), 'cjkencodings')
|
|
|
|
with open(os.path.join(dir, name + '.txt'), 'rb') as f:
|
|
|
|
encoded = f.read()
|
|
|
|
with open(os.path.join(dir, name + '-utf8.txt'), 'rb') as f:
|
|
|
|
utf8 = f.read()
|
|
|
|
return encoded, utf8
|