From 9774207b622966c8a5172156439c0d41c0335f33 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Fri, 18 Oct 2019 16:03:22 +1100 Subject: [PATCH] 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 --- tests/test_future/test_urllib2.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/test_future/test_urllib2.py b/tests/test_future/test_urllib2.py index e7fb4dd7..2d69dad1 100644 --- a/tests/test_future/test_urllib2.py +++ b/tests/test_future/test_urllib2.py @@ -691,6 +691,10 @@ def connect_ftp(self, user, passwd, host, port, dirs, h = NullFTPHandler(data) h.parent = MockOpener() + # MIME guessing works in Python 3.8! + guessed_mime = None + if sys.hexversion >= 0x03080000: + guessed_mime = "image/gif" for url, host, port, user, passwd, type_, dirs, filename, mimetype in [ ("ftp://localhost/foo/bar/baz.html", "localhost", ftplib.FTP_PORT, "", "", "I", @@ -709,7 +713,7 @@ def connect_ftp(self, user, passwd, host, port, dirs, ["foo", "bar"], "", None), ("ftp://localhost/baz.gif;type=a", "localhost", ftplib.FTP_PORT, "", "", "A", - [], "baz.gif", None), # XXX really this should guess image/gif + [], "baz.gif", guessed_mime), ]: req = Request(url) req.timeout = None