8
8
from future import utils
9
9
10
10
from numbers import Integral
11
- from future .tests .base import unittest , expectedFailurePY2
11
+ from future .tests .base import unittest , expectedFailurePY2 , expectedFailurePY33_and_PY34
12
12
13
13
14
14
TEST_UNICODE_STR = u'ℝεα∂@ßʟ℮ ☂ℯṧт υηḯ¢☺ḓ℮'
@@ -552,7 +552,7 @@ def test_maketrans(self):
552
552
self .assertRaises (ValueError , bytes .maketrans , b'abc' , b'xyzq' )
553
553
self .assertRaises (TypeError , bytes .maketrans , 'abc' , 'def' )
554
554
555
- @unittest . expectedFailure
555
+ @expectedFailurePY33_and_PY34
556
556
def test_mod (self ):
557
557
"""
558
558
From Py3.5 test suite (post-PEP 461).
@@ -569,7 +569,7 @@ def test_mod(self):
569
569
a = b % (b'seventy-nine' , 79 )
570
570
self .assertEqual (a , b'seventy-nine / 100 = 79%' )
571
571
572
- @unittest . expectedFailure
572
+ @expectedFailurePY33_and_PY34
573
573
def test_imod (self ):
574
574
"""
575
575
From Py3.5 test suite (post-PEP 461)
@@ -586,7 +586,7 @@ def test_imod(self):
586
586
b %= (b'seventy-nine' , 79 )
587
587
self .assertEqual (b , b'seventy-nine / 100 = 79%' )
588
588
589
- @unittest . expectedFailure
589
+ @expectedFailurePY33_and_PY34
590
590
def test_mod_pep_461 (self ):
591
591
"""
592
592
Test for the PEP 461 functionality (resurrection of %s formatting for
@@ -621,9 +621,10 @@ def test_mod_pep_461(self):
621
621
# is supposed to be equivalent to
622
622
# ("%x" % val).encode("ascii")
623
623
for code in b'xdiouxXeEfFgG' :
624
- pct_str = u"%" + code .decode ('ascii' )
624
+ bytechar = bytes ([code ])
625
+ pct_str = u"%" + bytechar .decode ('ascii' )
625
626
for val in range (300 ):
626
- self .assertEqual (bytes (b"%" + code ) % val ,
627
+ self .assertEqual (bytes (b"%" + bytechar ) % val ,
627
628
(pct_str % val ).encode ("ascii" ))
628
629
629
630
with self .assertRaises (TypeError ):
@@ -645,12 +646,12 @@ def test_mod_pep_461(self):
645
646
646
647
self .assertEqual (bytes (b'%a' ) % 'def' , b"'def'" )
647
648
648
- # PEP 461 specifes that %r is not supported.
649
- with self . assertRaises ( TypeError ):
650
- bytes (b'%r ' % b'abc' )
649
+ # PEP 461 was updated after an Py3.5 alpha release to specify that %r is now supported
650
+ # for compatibility: http://legacy.python.org/dev/peps/pep-0461/#id16
651
+ assert bytes ( b'%r' % b'abc' ) == bytes (b'%a ' % b'abc' )
651
652
652
- with self .assertRaises (TypeError ):
653
- bytes (b'%r' % 'abc' )
653
+ # with self.assertRaises(TypeError):
654
+ # bytes(b'%r' % 'abc')
654
655
655
656
@expectedFailurePY2
656
657
def test_multiple_inheritance (self ):
0 commit comments