Merged revisions 84470-84471,84566-84567,84759 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r84470 | florent.xicluna | 2010-09-03 22:00:37 +0200 (ven., 03 sept. 2010) | 1 line Strengthen BytesWarning tests. ........ r84471 | florent.xicluna | 2010-09-03 22:23:40 +0200 (ven., 03 sept. 2010) | 1 line Typo ........ r84566 | florent.xicluna | 2010-09-06 22:27:15 +0200 (lun., 06 sept. 2010) | 1 line typo ........ r84567 | florent.xicluna | 2010-09-06 22:27:55 +0200 (lun., 06 sept. 2010) | 1 line typo ........ r84759 | florent.xicluna | 2010-09-13 04:28:18 +0200 (lun., 13 sept. 2010) | 1 line Reenable test_ucs4 and remove some duplicated lines. ........
This commit is contained in:
parent
f994f04745
commit
9b90cd1f7b
|
@ -836,7 +836,7 @@ leading dot means the current package where the module making the import
|
||||||
exists. Two dots means up one package level. Three dots is up two levels, etc.
|
exists. Two dots means up one package level. Three dots is up two levels, etc.
|
||||||
So if you execute ``from . import mod`` from a module in the ``pkg`` package
|
So if you execute ``from . import mod`` from a module in the ``pkg`` package
|
||||||
then you will end up importing ``pkg.mod``. If you execute ``from ..subpkg2
|
then you will end up importing ``pkg.mod``. If you execute ``from ..subpkg2
|
||||||
imprt mod`` from within ``pkg.subpkg1`` you will import ``pkg.subpkg2.mod``.
|
import mod`` from within ``pkg.subpkg1`` you will import ``pkg.subpkg2.mod``.
|
||||||
The specification for relative imports is contained within :pep:`328`.
|
The specification for relative imports is contained within :pep:`328`.
|
||||||
|
|
||||||
:func:`importlib.import_module` is provided to support applications that
|
:func:`importlib.import_module` is provided to support applications that
|
||||||
|
|
|
@ -607,7 +607,7 @@ class Formatter(object):
|
||||||
return str(value)
|
return str(value)
|
||||||
elif conversion is None:
|
elif conversion is None:
|
||||||
return value
|
return value
|
||||||
raise ValueError("Unknown converion specifier {0!s}".format(conversion))
|
raise ValueError("Unknown conversion specifier {0!s}".format(conversion))
|
||||||
|
|
||||||
|
|
||||||
# returns an iterable that contains tuples of the form:
|
# returns an iterable that contains tuples of the form:
|
||||||
|
|
|
@ -1119,7 +1119,7 @@ class MixinStrUnicodeUserStringTest:
|
||||||
format = '%%.%if' % prec
|
format = '%%.%if' % prec
|
||||||
value = 0.01
|
value = 0.01
|
||||||
for x in xrange(60):
|
for x in xrange(60):
|
||||||
value = value * 3.141592655 / 3.0 * 10.0
|
value = value * 3.14159265359 / 3.0 * 10.0
|
||||||
self.checkcall(format, "__mod__", value)
|
self.checkcall(format, "__mod__", value)
|
||||||
|
|
||||||
def test_inplace_rewrites(self):
|
def test_inplace_rewrites(self):
|
||||||
|
|
|
@ -9,14 +9,28 @@ import os
|
||||||
import re
|
import re
|
||||||
import sys
|
import sys
|
||||||
import copy
|
import copy
|
||||||
|
import functools
|
||||||
import pickle
|
import pickle
|
||||||
import tempfile
|
import tempfile
|
||||||
import unittest
|
import unittest
|
||||||
import warnings
|
|
||||||
import test.test_support
|
import test.test_support
|
||||||
import test.string_tests
|
import test.string_tests
|
||||||
import test.buffer_tests
|
import test.buffer_tests
|
||||||
|
|
||||||
|
|
||||||
|
if sys.flags.bytes_warning:
|
||||||
|
def check_bytes_warnings(func):
|
||||||
|
@functools.wraps(func)
|
||||||
|
def wrapper(*args, **kw):
|
||||||
|
with test.test_support.check_warnings(('', BytesWarning)):
|
||||||
|
return func(*args, **kw)
|
||||||
|
return wrapper
|
||||||
|
else:
|
||||||
|
# no-op
|
||||||
|
def check_bytes_warnings(func):
|
||||||
|
return func
|
||||||
|
|
||||||
|
|
||||||
class Indexable:
|
class Indexable:
|
||||||
def __init__(self, value=0):
|
def __init__(self, value=0):
|
||||||
self.value = value
|
self.value = value
|
||||||
|
@ -26,12 +40,6 @@ class Indexable:
|
||||||
|
|
||||||
class BaseBytesTest(unittest.TestCase):
|
class BaseBytesTest(unittest.TestCase):
|
||||||
|
|
||||||
def setUp(self):
|
|
||||||
self.warning_filters = warnings.filters[:]
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
warnings.filters = self.warning_filters
|
|
||||||
|
|
||||||
def test_basics(self):
|
def test_basics(self):
|
||||||
b = self.type2test()
|
b = self.type2test()
|
||||||
self.assertEqual(type(b), self.type2test)
|
self.assertEqual(type(b), self.type2test)
|
||||||
|
@ -120,8 +128,8 @@ class BaseBytesTest(unittest.TestCase):
|
||||||
self.assertFalse(b3 < b2)
|
self.assertFalse(b3 < b2)
|
||||||
self.assertFalse(b3 <= b2)
|
self.assertFalse(b3 <= b2)
|
||||||
|
|
||||||
|
@check_bytes_warnings
|
||||||
def test_compare_to_str(self):
|
def test_compare_to_str(self):
|
||||||
warnings.simplefilter('ignore', BytesWarning)
|
|
||||||
# Byte comparisons with unicode should always fail!
|
# Byte comparisons with unicode should always fail!
|
||||||
# Test this for all expected byte orders and Unicode character sizes
|
# Test this for all expected byte orders and Unicode character sizes
|
||||||
self.assertEqual(self.type2test(b"\0a\0b\0c") == u"abc", False)
|
self.assertEqual(self.type2test(b"\0a\0b\0c") == u"abc", False)
|
||||||
|
@ -795,14 +803,8 @@ class AssortedBytesTest(unittest.TestCase):
|
||||||
# Test various combinations of bytes and bytearray
|
# Test various combinations of bytes and bytearray
|
||||||
#
|
#
|
||||||
|
|
||||||
def setUp(self):
|
@check_bytes_warnings
|
||||||
self.warning_filters = warnings.filters[:]
|
|
||||||
|
|
||||||
def tearDown(self):
|
|
||||||
warnings.filters = self.warning_filters
|
|
||||||
|
|
||||||
def test_repr_str(self):
|
def test_repr_str(self):
|
||||||
warnings.simplefilter('ignore', BytesWarning)
|
|
||||||
for f in str, repr:
|
for f in str, repr:
|
||||||
self.assertEqual(f(bytearray()), "bytearray(b'')")
|
self.assertEqual(f(bytearray()), "bytearray(b'')")
|
||||||
self.assertEqual(f(bytearray([0])), "bytearray(b'\\x00')")
|
self.assertEqual(f(bytearray([0])), "bytearray(b'\\x00')")
|
||||||
|
@ -853,8 +855,8 @@ class AssortedBytesTest(unittest.TestCase):
|
||||||
b = bytearray(buf)
|
b = bytearray(buf)
|
||||||
self.assertEqual(b, bytearray(sample))
|
self.assertEqual(b, bytearray(sample))
|
||||||
|
|
||||||
|
@check_bytes_warnings
|
||||||
def test_to_str(self):
|
def test_to_str(self):
|
||||||
warnings.simplefilter('ignore', BytesWarning)
|
|
||||||
self.assertEqual(str(b''), "b''")
|
self.assertEqual(str(b''), "b''")
|
||||||
self.assertEqual(str(b'x'), "b'x'")
|
self.assertEqual(str(b'x'), "b'x'")
|
||||||
self.assertEqual(str(b'\x80'), "b'\\x80'")
|
self.assertEqual(str(b'\x80'), "b'\\x80'")
|
||||||
|
|
|
@ -593,9 +593,9 @@ class UnicodeTest(
|
||||||
)
|
)
|
||||||
|
|
||||||
# UTF-8 specific decoding tests
|
# UTF-8 specific decoding tests
|
||||||
self.assertEqual(unicode('\xf0\xa3\x91\x96', 'utf-8'), u'\U00023456' )
|
self.assertEqual(unicode('\xf0\xa3\x91\x96', 'utf-8'), u'\U00023456')
|
||||||
self.assertEqual(unicode('\xf0\x90\x80\x82', 'utf-8'), u'\U00010002' )
|
self.assertEqual(unicode('\xf0\x90\x80\x82', 'utf-8'), u'\U00010002')
|
||||||
self.assertEqual(unicode('\xe2\x82\xac', 'utf-8'), u'\u20ac' )
|
self.assertEqual(unicode('\xe2\x82\xac', 'utf-8'), u'\u20ac')
|
||||||
|
|
||||||
# Other possible utf-8 test cases:
|
# Other possible utf-8 test cases:
|
||||||
# * strict decoding testing for all of the
|
# * strict decoding testing for all of the
|
||||||
|
@ -1360,8 +1360,8 @@ class UnicodeTest(
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return u'__unicode__ overridden'
|
return u'__unicode__ overridden'
|
||||||
u = U(u'xxx')
|
u = U(u'xxx')
|
||||||
self.assertEquals("%s" % u, u'__unicode__ overridden')
|
self.assertEqual("%s" % u, u'__unicode__ overridden')
|
||||||
self.assertEquals("{}".format(u), u'__unicode__ overridden')
|
self.assertEqual("{}".format(u), u'__unicode__ overridden')
|
||||||
|
|
||||||
|
|
||||||
def test_main():
|
def test_main():
|
||||||
|
|
|
@ -72,7 +72,7 @@
|
||||||
|
|
||||||
It is possible to support both the 2.0 and 2.2 GC APIs, but it's
|
It is possible to support both the 2.0 and 2.2 GC APIs, but it's
|
||||||
not pretty and this comment block is too narrow to contain a
|
not pretty and this comment block is too narrow to contain a
|
||||||
desciption of what's required... */
|
description of what's required... */
|
||||||
|
|
||||||
#if PY_VERSION_HEX < 0x020200B1
|
#if PY_VERSION_HEX < 0x020200B1
|
||||||
#define PyObject_GC_New PyObject_New
|
#define PyObject_GC_New PyObject_New
|
||||||
|
|
Loading…
Reference in New Issue