From 579a197e8a7736a5ed1148d9cb11c46576c60f6e Mon Sep 17 00:00:00 2001 From: Jordan Adler Date: Fri, 19 Oct 2018 15:09:47 -0700 Subject: [PATCH 1/2] Fix tests on Py3 --- src/future/utils/__init__.py | 2 +- tests/test_future/test_bytes.py | 10 +++++----- tests/test_future/test_urllibnet.py | 4 +++- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/src/future/utils/__init__.py b/src/future/utils/__init__.py index 38a3026e..a6bbab06 100644 --- a/src/future/utils/__init__.py +++ b/src/future/utils/__init__.py @@ -56,7 +56,7 @@ PY3 = sys.version_info[0] == 3 -PY35 = sys.version_info[0:2] >= (3, 5) +PY35_PLUS = sys.version_info[0:2] >= (3, 5) PY2 = sys.version_info[0] == 2 PY26 = sys.version_info[0:2] == (2, 6) PY27 = sys.version_info[0:2] == (2, 7) diff --git a/tests/test_future/test_bytes.py b/tests/test_future/test_bytes.py index 42dd81cf..bb90a71c 100644 --- a/tests/test_future/test_bytes.py +++ b/tests/test_future/test_bytes.py @@ -566,7 +566,7 @@ class MyDict(UserDict.UserDict): self.assertEqual(bytes(b'%(foo)s') % d, b'bar') - @unittest.skipUnless(utils.PY35 or utils.PY2, + @unittest.skipUnless(utils.PY35_PLUS or utils.PY2, 'test requires Python 2 or 3.5+') def test_mod_more(self): self.assertEqual(b'%s' % b'aaa', b'aaa') @@ -577,10 +577,10 @@ def test_mod_more(self): self.assertEqual(bytes(b'%s') % (b'aaa',), b'aaa') self.assertEqual(bytes(b'%s') % (bytes(b'aaa'),), b'aaa') - self.assertEqual(bytes(b'%(x)s') % {'x': b'aaa'}, b'aaa') - self.assertEqual(bytes(b'%(x)s') % {'x': bytes(b'aaa')}, b'aaa') + self.assertEqual(bytes(b'%(x)s') % {b'x': b'aaa'}, b'aaa') + self.assertEqual(bytes(b'%(x)s') % {b'x': bytes(b'aaa')}, b'aaa') - @unittest.skipUnless(utils.PY35 or utils.PY2, + @unittest.skipUnless(utils.PY35_PLUS or utils.PY2, 'test requires Python 2 or 3.5+') def test_mod(self): """ @@ -606,7 +606,7 @@ def test_mod(self): a = b % (bytes(b'seventy-nine'), 79) self.assertEqual(a, b'seventy-nine / 100 = 79%') - @unittest.skipUnless(utils.PY35 or utils.PY2, + @unittest.skipUnless(utils.PY35_PLUS or utils.PY2, 'test requires Python 2 or 3.5+') def test_imod(self): """ diff --git a/tests/test_future/test_urllibnet.py b/tests/test_future/test_urllibnet.py index f5f59875..bc087258 100644 --- a/tests/test_future/test_urllibnet.py +++ b/tests/test_future/test_urllibnet.py @@ -109,7 +109,9 @@ def test_getcode(self): # On Windows, socket handles are not file descriptors; this # test can't pass on Windows. - @unittest.skipIf(sys.platform in ('win32',), 'not appropriate for Windows') + # + # On macOS, this behavior is undocumented and this test fails. + @unittest.skipIf(sys.platform in ('darwin', 'win32',), 'not appropriate for macOS or Windows') @skip26 def test_fileno(self): # Make sure fd returned by fileno is valid. From b9212afa331174bc1389abd747323fd799232f61 Mon Sep 17 00:00:00 2001 From: Jordan Adler Date: Fri, 19 Oct 2018 15:21:15 -0700 Subject: [PATCH 2/2] Skip the test not if it is OSX, but if it is Py3.6+, which appears to be the origination of the behavior breakage --- src/future/utils/__init__.py | 1 + tests/test_future/test_urllibnet.py | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/future/utils/__init__.py b/src/future/utils/__init__.py index a6bbab06..906f1e46 100644 --- a/src/future/utils/__init__.py +++ b/src/future/utils/__init__.py @@ -57,6 +57,7 @@ PY3 = sys.version_info[0] == 3 PY35_PLUS = sys.version_info[0:2] >= (3, 5) +PY36_PLUS = sys.version_info[0:2] >= (3, 6) PY2 = sys.version_info[0] == 2 PY26 = sys.version_info[0:2] == (2, 6) PY27 = sys.version_info[0:2] == (2, 7) diff --git a/tests/test_future/test_urllibnet.py b/tests/test_future/test_urllibnet.py index bc087258..f9639bfc 100644 --- a/tests/test_future/test_urllibnet.py +++ b/tests/test_future/test_urllibnet.py @@ -109,9 +109,8 @@ def test_getcode(self): # On Windows, socket handles are not file descriptors; this # test can't pass on Windows. - # - # On macOS, this behavior is undocumented and this test fails. - @unittest.skipIf(sys.platform in ('darwin', 'win32',), 'not appropriate for macOS or Windows') + @unittest.skipIf(sys.platform in ('darwin', 'win32',), 'not appropriate for Windows') + @unittest.skipIf(utils.PY36_PLUS, 'test not applicable on Python 3.5 and higher') @skip26 def test_fileno(self): # Make sure fd returned by fileno is valid.