Skip to content

Commit 74d8343

Browse files
committed
Test fixes
1 parent 4fcbe2e commit 74d8343

File tree

5 files changed

+21
-10
lines changed

5 files changed

+21
-10
lines changed

src/future/moves/test/support.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
from __future__ import absolute_import
2+
3+
import sys
4+
25
from future.standard_library import suspend_hooks
36
from future.utils import PY3
47

58
if PY3:
69
from test.support import *
10+
if sys.version_info[:2] >= (3, 10):
11+
from test.support.os_helper import (
12+
EnvironmentVarGuard,
13+
TESTFN,
14+
)
15+
from test.support.warnings_helper import check_warnings
716
else:
817
__future_module__ = True
918
with suspend_hooks():

tests/test_future/test_builtins.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,8 +1303,11 @@ def test_pow(self):
13031303
self.assertAlmostEqual(pow(-1, 0.5), 1j)
13041304
self.assertAlmostEqual(pow(-1, 1/3), 0.5 + 0.8660254037844386j)
13051305

1306-
# Raises TypeError in Python < v3.5, ValueError in v3.5:
1307-
self.assertRaises((TypeError, ValueError), pow, -1, -2, 3)
1306+
# Raises TypeError in Python < v3.5, ValueError in v3.5-v3.7:
1307+
if sys.version_info[:2] < (3, 8):
1308+
self.assertRaises((TypeError, ValueError), pow, -1, -2, 3)
1309+
else:
1310+
self.assertEqual(pow(-1, -2, 3), 1)
13081311
self.assertRaises(ValueError, pow, 1, 2, 0)
13091312

13101313
self.assertRaises(TypeError, pow)

tests/test_future/test_urllib2.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -691,10 +691,6 @@ def connect_ftp(self, user, passwd, host, port, dirs,
691691
h = NullFTPHandler(data)
692692
h.parent = MockOpener()
693693

694-
# MIME guessing works in Python 3.8!
695-
guessed_mime = None
696-
if sys.hexversion >= 0x03080000:
697-
guessed_mime = "image/gif"
698694
for url, host, port, user, passwd, type_, dirs, filename, mimetype in [
699695
("ftp://localhost/foo/bar/baz.html",
700696
"localhost", ftplib.FTP_PORT, "", "", "I",
@@ -713,7 +709,7 @@ def connect_ftp(self, user, passwd, host, port, dirs,
713709
["foo", "bar"], "", None),
714710
("ftp://localhost/baz.gif;type=a",
715711
"localhost", ftplib.FTP_PORT, "", "", "A",
716-
[], "baz.gif", guessed_mime),
712+
[], "baz.gif", None),
717713
]:
718714
req = Request(url)
719715
req.timeout = None

tests/test_future/test_urllib_toplevel.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -781,8 +781,11 @@ def test_unquoting(self):
781781
"%s" % result)
782782
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, None)
783783
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, ())
784-
with support.check_warnings(('', BytesWarning), quiet=True):
785-
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, bytes(b''))
784+
if sys.version_info[:2] < (3, 9):
785+
with support.check_warnings(('', BytesWarning), quiet=True):
786+
self.assertRaises((TypeError, AttributeError), urllib_parse.unquote, bytes(b''))
787+
else:
788+
self.assertEqual(urllib_parse.unquote(bytes(b"")), "")
786789

787790
def test_unquoting_badpercent(self):
788791
# Test unquoting on bad percent-escapes

tests/test_future/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ class Timeout(BaseException):
150150
self.assertRaises(Timeout, raise_, Timeout())
151151

152152
if PY3:
153-
self.assertRaisesRegexp(
153+
self.assertRaisesRegex(
154154
TypeError, "class must derive from BaseException",
155155
raise_, int)
156156

0 commit comments

Comments
 (0)