Skip to content

Commit 8ab0ae0

Browse files
committed
Mark PEP 461 tests as expected to pass on Py3.5
1 parent d25f4f8 commit 8ab0ae0

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/future/tests/base.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import re
77
import warnings
88
import io
9-
import functools
109
from textwrap import dedent
1110

1211
from future.utils import bind_method, PY26, PY3, PY2, PY27
@@ -378,6 +377,10 @@ def expectedFailurePY3(func):
378377
return func
379378
return unittest.expectedFailure(func)
380379

380+
def expectedFailurePY33_and_PY34(func):
381+
if sys.version_info[:2] not in {(3, 3), (3, 4)}:
382+
return func
383+
return unittest.expectedFailure(func)
381384

382385
def expectedFailurePY26(func):
383386
if not PY26:

tests/test_future/test_bytes.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from future import utils
99

1010
from numbers import Integral
11-
from future.tests.base import unittest, expectedFailurePY2
11+
from future.tests.base import unittest, expectedFailurePY2, expectedFailurePY33_and_PY34
1212

1313

1414
TEST_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

Comments
 (0)