88from future import utils
99
1010from numbers import Integral
11- from future .tests .base import unittest , expectedFailurePY2
11+ from future .tests .base import unittest , expectedFailurePY2 , expectedFailurePY33_and_PY34
1212
1313
1414TEST_UNICODE_STR = u'ℝεα∂@ßʟ℮ ☂ℯṧт υηḯ¢☺ḓ℮'
@@ -552,7 +552,7 @@ def test_maketrans(self):
552552 self .assertRaises (ValueError , bytes .maketrans , b'abc' , b'xyzq' )
553553 self .assertRaises (TypeError , bytes .maketrans , 'abc' , 'def' )
554554
555- @unittest . expectedFailure
555+ @expectedFailurePY33_and_PY34
556556 def test_mod (self ):
557557 """
558558 From Py3.5 test suite (post-PEP 461).
@@ -569,7 +569,7 @@ def test_mod(self):
569569 a = b % (b'seventy-nine' , 79 )
570570 self .assertEqual (a , b'seventy-nine / 100 = 79%' )
571571
572- @unittest . expectedFailure
572+ @expectedFailurePY33_and_PY34
573573 def test_imod (self ):
574574 """
575575 From Py3.5 test suite (post-PEP 461)
@@ -586,7 +586,7 @@ def test_imod(self):
586586 b %= (b'seventy-nine' , 79 )
587587 self .assertEqual (b , b'seventy-nine / 100 = 79%' )
588588
589- @unittest . expectedFailure
589+ @expectedFailurePY33_and_PY34
590590 def test_mod_pep_461 (self ):
591591 """
592592 Test for the PEP 461 functionality (resurrection of %s formatting for
@@ -621,9 +621,10 @@ def test_mod_pep_461(self):
621621 # is supposed to be equivalent to
622622 # ("%x" % val).encode("ascii")
623623 for code in b'xdiouxXeEfFgG' :
624- pct_str = u"%" + code .decode ('ascii' )
624+ bytechar = bytes ([code ])
625+ pct_str = u"%" + bytechar .decode ('ascii' )
625626 for val in range (300 ):
626- self .assertEqual (bytes (b"%" + code ) % val ,
627+ self .assertEqual (bytes (b"%" + bytechar ) % val ,
627628 (pct_str % val ).encode ("ascii" ))
628629
629630 with self .assertRaises (TypeError ):
@@ -645,12 +646,12 @@ def test_mod_pep_461(self):
645646
646647 self .assertEqual (bytes (b'%a' ) % 'def' , b"'def'" )
647648
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' )
651652
652- with self .assertRaises (TypeError ):
653- bytes (b'%r' % 'abc' )
653+ # with self.assertRaises(TypeError):
654+ # bytes(b'%r' % 'abc')
654655
655656 @expectedFailurePY2
656657 def test_multiple_inheritance (self ):
0 commit comments