Skip to content

Commit 9774207

Browse files
committed
MIME guessing works in Python 3.8 in test_urllib2
To continue to support other versions of Python, use sys.hexversion to check if we're using 3.8 and set the MIME type appropriately. Fixes #508
1 parent a3e303f commit 9774207

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

tests/test_future/test_urllib2.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,10 @@ 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"
694698
for url, host, port, user, passwd, type_, dirs, filename, mimetype in [
695699
("ftp://localhost/foo/bar/baz.html",
696700
"localhost", ftplib.FTP_PORT, "", "", "I",
@@ -709,7 +713,7 @@ def connect_ftp(self, user, passwd, host, port, dirs,
709713
["foo", "bar"], "", None),
710714
("ftp://localhost/baz.gif;type=a",
711715
"localhost", ftplib.FTP_PORT, "", "", "A",
712-
[], "baz.gif", None), # XXX really this should guess image/gif
716+
[], "baz.gif", guessed_mime),
713717
]:
714718
req = Request(url)
715719
req.timeout = None

0 commit comments

Comments
 (0)