2020# import UserDict
2121from os import unlink
2222from operator import neg
23- from future .tests .base import unittest
23+ from future .tests .base import unittest , expectedFailurePY3
2424
2525# count the number of test runs.
2626# used to skip running test_execfile() multiple times
@@ -169,6 +169,7 @@ def test_neg(self):
169169 self .assertTrue (isinstance (x , int ))
170170 self .assertEqual (- x , sys .maxsize + 1 )
171171
172+ @expectedFailurePY3
172173 def test_apply (self ):
173174 def f0 (* args ):
174175 self .assertEqual (args , ())
@@ -195,6 +196,11 @@ def f3(a1, a2, a3):
195196 self .assertRaises (TypeError , apply , id , 42 )
196197 self .assertRaises (TypeError , apply , id , (42 ,), 42 )
197198
199+ def test_basestring (self ):
200+ assert isinstance ('hello' , basestring )
201+ assert isinstance (b'hello' , basestring )
202+
203+ @expectedFailurePY3
198204 def test_callable (self ):
199205 self .assertTrue (callable (len ))
200206 self .assertFalse (callable ("a" ))
@@ -236,6 +242,7 @@ class N3(N2): pass
236242 n3 = N3 ()
237243 self .assertTrue (callable (n3 ))
238244
245+ @expectedFailurePY3
239246 def test_chr (self ):
240247 self .assertEqual (chr (32 ), ' ' )
241248 self .assertEqual (chr (65 ), 'A' )
@@ -244,6 +251,7 @@ def test_chr(self):
244251 self .assertRaises (ValueError , chr , 256 )
245252 self .assertRaises (TypeError , chr )
246253
254+ @expectedFailurePY3
247255 def test_cmp (self ):
248256 self .assertEqual (cmp (- 1 , 1 ), - 1 )
249257 self .assertEqual (cmp (1 , - 1 ), 1 )
@@ -261,6 +269,7 @@ def test_cmp(self):
261269 a .pop (); b .pop (); c .pop ()
262270 self .assertRaises (TypeError , cmp )
263271
272+ @expectedFailurePY3
264273 def test_coerce (self ):
265274 self .assertTrue (not fcmp (coerce (1 , 1.1 ), (1.0 , 1.1 )))
266275 self .assertEqual (coerce (1 , 1 ), (1 , 1 ))
@@ -272,6 +281,7 @@ def __coerce__(self, other):
272281 self .assertRaises (ValueError , coerce , 42 , BadNumber ())
273282 self .assertRaises (OverflowError , coerce , 0.5 , int ("12345" * 1000 ))
274283
284+ @expectedFailurePY3
275285 def test_compile (self ):
276286 compile ('print(1)\n ' , '' , 'exec' )
277287 bom = '\xef \xbb \xbf '
@@ -385,6 +395,7 @@ def test_divmod(self):
385395
386396 self .assertRaises (TypeError , divmod )
387397
398+ @expectedFailurePY3
388399 def test_eval (self ):
389400 self .assertEqual (eval ('1+1' ), 2 )
390401 self .assertEqual (eval (' 1+1\n ' ), 2 )
@@ -411,6 +422,7 @@ def test_eval(self):
411422 self .assertRaises (TypeError , eval )
412423 self .assertRaises (TypeError , eval , ())
413424
425+ @expectedFailurePY3
414426 def test_general_eval (self ):
415427 # Tests that general mappings can be used for the locals argument
416428
@@ -535,6 +547,7 @@ def __setitem__(self, key, value):
535547 self .assertRaises (IOError , execfile , os .curdir )
536548 self .assertRaises (IOError , execfile , "I_dont_exist" )
537549
550+ @expectedFailurePY3
538551 def test_filter (self ):
539552 self .assertEqual (filter (lambda c : 'a' <= c <= 'z' , 'Hello World' ), 'elloorld' )
540553 self .assertEqual (filter (None , [1 , 'hello' , [], [3 ], '' , None , 9 , 0 ]), [1 , 'hello' , [3 ], 9 ])
@@ -610,6 +623,7 @@ def __getitem__(self, index):
610623 unicode ("345" )
611624 )
612625
626+ @expectedFailurePY3
613627 def test_filter_subclasses (self ):
614628 # test that filter() never returns tuple, str or unicode subclasses
615629 # and that the result always goes through __getitem__
@@ -646,6 +660,7 @@ def __getitem__(self, index):
646660 self .assertEqual (outp , exp )
647661 self .assertTrue (not isinstance (outp , cls ))
648662
663+ @expectedFailurePY3
649664 def test_getattr (self ):
650665 import sys
651666 self .assertTrue (getattr (sys , 'stdout' ) is sys .stdout )
@@ -655,6 +670,7 @@ def test_getattr(self):
655670 if True : # Was: have_unicode:
656671 self .assertRaises (UnicodeError , getattr , sys , unichr (sys .maxunicode ))
657672
673+ @expectedFailurePY3
658674 def test_hasattr (self ):
659675 import sys
660676 self .assertTrue (hasattr (sys , 'stdout' ))
@@ -719,6 +735,7 @@ def test_id(self):
719735
720736 # test_int(): see test_int.py for int() tests.
721737
738+ @expectedFailurePY3
722739 def test_intern (self ):
723740 self .assertRaises (TypeError , intern )
724741 # This fails if the test is run twice with a constant string,
@@ -745,6 +762,7 @@ def __hash__(self):
745762 setattr (s , s , s )
746763 self .assertEqual (getattr (s , s ), s )
747764
765+ @expectedFailurePY3
748766 def test_iter (self ):
749767 self .assertRaises (TypeError , iter )
750768 self .assertRaises (TypeError , iter , 42 , 42 )
@@ -792,6 +810,7 @@ class E:
792810 self .assertRaises (TypeError , issubclass , E , 'foo' )
793811 self .assertRaises (TypeError , issubclass )
794812
813+ @expectedFailurePY3
795814 def test_len (self ):
796815 self .assertEqual (len ('123' ), 3 )
797816 self .assertEqual (len (()), 0 )
@@ -918,6 +937,7 @@ def test_max(self):
918937 self .assertEqual (max (data , key = f ),
919938 sorted (reversed (data ), key = f )[- 1 ])
920939
940+ @expectedFailurePY3
921941 def test_min (self ):
922942 self .assertEqual (min ('123123' ), '1' )
923943 self .assertEqual (min (1 , 2 , 3 ), 1 )
@@ -964,6 +984,7 @@ def __cmp__(self, other):
964984 self .assertEqual (min (data , key = f ),
965985 sorted (data , key = f )[0 ])
966986
987+ @expectedFailurePY3
967988 def test_next (self ):
968989 it = iter (range (2 ))
969990 self .assertEqual (next (it ), 0 )
@@ -991,6 +1012,7 @@ def gen():
9911012 self .assertRaises (StopIteration , next , it )
9921013 self .assertEqual (next (it , 42 ), 42 )
9931014
1015+ @expectedFailurePY3
9941016 def test_oct (self ):
9951017 self .assertEqual (oct (100 ), '0144' )
9961018 # self.assertEqual(oct(100L), '0144L')
@@ -1027,6 +1049,7 @@ def test_open(self):
10271049 fp .close ()
10281050 unlink (TESTFN )
10291051
1052+ @expectedFailurePY3
10301053 def test_ord (self ):
10311054 self .assertEqual (ord (' ' ), 32 )
10321055 self .assertEqual (ord ('A' ), 65 )
@@ -1037,6 +1060,7 @@ def test_ord(self):
10371060 if True : # Was: if have_unicode:
10381061 self .assertRaises (TypeError , ord , unicode ("12" ))
10391062
1063+ @expectedFailurePY3
10401064 def test_pow (self ):
10411065 self .assertEqual (pow (0 ,0 ), 1 )
10421066 self .assertEqual (pow (0 ,1 ), 0 )
@@ -1102,6 +1126,7 @@ def test_pow(self):
11021126
11031127 self .assertRaises (TypeError , pow )
11041128
1129+ @expectedFailurePY3
11051130 def test_range (self ):
11061131 self .assertEqual (range (3 ), [0 , 1 , 2 ])
11071132 self .assertEqual (range (1 , 5 ), [1 , 2 , 3 , 4 ])
@@ -1208,8 +1233,7 @@ def __int__(self):
12081233 self .assertRaises (TypeError , range , 0.0 , 0.0 , 1 )
12091234 self .assertRaises (TypeError , range , 0.0 , 0.0 , 1.0 )
12101235
1211-
1212-
1236+ @expectedFailurePY3
12131237 def test_input_and_raw_input (self ):
12141238 self .write_testfile ()
12151239 fp = open (TESTFN , 'r' )
@@ -1324,6 +1348,7 @@ def test_repr(self):
13241348 a [0 ] = a
13251349 self .assertEqual (repr (a ), '{0: {...}}' )
13261350
1351+ @expectedFailurePY3
13271352 def test_round (self ):
13281353 self .assertEqual (round (0.0 ), 0.0 )
13291354 self .assertEqual (type (round (0.0 )), float ) # Will be int in 3.0.
@@ -1454,6 +1479,7 @@ def test_type(self):
14541479 self .assertEqual (type ('' ), type ('123' ))
14551480 self .assertNotEqual (type ('' ), type (()))
14561481
1482+ @expectedFailurePY3
14571483 def test_unichr (self ):
14581484 if True : # Was: if have_unicode:
14591485 self .assertEqual (unichr (32 ), unicode (' ' ))
@@ -1538,6 +1564,7 @@ def __getitem__(self, i):
15381564 return i
15391565 self .assertRaises (ValueError , zip , BadSeq (), BadSeq ())
15401566
1567+ @expectedFailurePY3
15411568 def test_format (self ):
15421569 # Test the basic machinery of the format() builtin. Don't test
15431570 # the specifics of the various formatters
@@ -1677,13 +1704,15 @@ def test_bin(self):
16771704 self .assertEqual (bin (- (2 ** 65 )), '-0b1' + '0' * 65 )
16781705 self .assertEqual (bin (- (2 ** 65 - 1 )), '-0b' + '1' * 65 )
16791706
1707+ @expectedFailurePY3
16801708 def test_bytearray_translate (self ):
16811709 x = bytearray (b"abc" )
16821710 self .assertRaises (ValueError , x .translate , "1" , 1 )
16831711 self .assertRaises (TypeError , x .translate , "1" * 256 , 1 )
16841712
16851713class TestSorted (unittest .TestCase ):
16861714
1715+ @expectedFailurePY3
16871716 def test_basic (self ):
16881717 data = range (100 )
16891718 copy = data [:]
0 commit comments