55import unittest , string , sys , struct
66from test import test_support
77from UserList import UserList
8+ import warnings
89
910class Sequence :
1011 def __init__ (self , seq = 'wxyz' ): self .seq = seq
@@ -1058,6 +1059,24 @@ def test_slice(self):
10581059
10591060 self .checkraises (TypeError , 'abc' , '__getslice__' , 'def' )
10601061
1062+ def test_py3x_warnings_isinstance (self ):
1063+ if sys .py3kwarning :
1064+ with warnings .catch_warnings (record = True ) as w :
1065+ warnings .filterwarnings ('always' , category = Py3xWarning )
1066+ isinstance (u"fix" , basestring )
1067+ isinstance (b"fix" , basestring )
1068+ isinstance ("fix" , basestring )
1069+
1070+ def test_py3x_warnings_join (self ):
1071+ if sys .py3kwarning :
1072+ with warnings .catch_warnings (record = True ) as w :
1073+ warnings .filterwarnings ('always' , category = Py3xWarning )
1074+ x = 'foo'
1075+ y = b'foo'
1076+ z = x + y
1077+ b = y + x
1078+ v = x .__add__ (y )
1079+
10611080 def test_extended_getslice (self ):
10621081 # Test extended slicing by comparing with list slicing.
10631082 s = string .ascii_letters + string .digits
@@ -1081,24 +1100,6 @@ def test_mul(self):
10811100 # but either raises a MemoryError, or succeeds (if you have 54TiB)
10821101 #self.checkraises(OverflowError, 10000*'abc', '__mul__', 2000000000)
10831102
1084- def test_py3x_warnings_isinstance (self ):
1085- with test_support .check_py3k_warnings (("the basestring type is not supported in 3.x: "
1086- "import a third party library like six and use"
1087- "a compatible type like string_types" , Py3xWarning )):
1088- isinstance (u"fix" , basestring )
1089- isinstance (b"fix" , basestring )
1090- isinstance ("fix" , basestring )
1091-
1092- def test_py3x_warnings_join (self ):
1093- with test_support .check_py3k_warnings (("mixed bytes, str and unicode operands cannot "
1094- "be used in string concatenation in Python 3.x: "
1095- "convert the operand(s) so that they are the same type." , Py3xWarning )):
1096- x = 'foo'
1097- y = b'foo'
1098- z = x + y
1099- b = y + x
1100- v = x .__add__ (y )
1101-
11021103 def test_join (self ):
11031104 # join now works with any sequence type
11041105 # moved here, because the argument order is
0 commit comments