Commit a96fd482 authored by Benjamin Peterson's avatar Benjamin Peterson

merge 3.2 (#20695)

parents 665a2bcd 1b94030b
...@@ -103,7 +103,7 @@ class urlopenNetworkTests(unittest.TestCase): ...@@ -103,7 +103,7 @@ class urlopenNetworkTests(unittest.TestCase):
# Make sure fd returned by fileno is valid. # Make sure fd returned by fileno is valid.
with self.urlopen("http://www.python.org/", timeout=None) as open_url: with self.urlopen("http://www.python.org/", timeout=None) as open_url:
fd = open_url.fileno() fd = open_url.fileno()
with os.fdopen(fd, encoding='utf-8') as f: with os.fdopen(fd, 'rb') as f:
self.assertTrue(f.read(), "reading from file created using fd " self.assertTrue(f.read(), "reading from file created using fd "
"returned by fileno failed") "returned by fileno failed")
...@@ -151,7 +151,7 @@ class urlretrieveNetworkTests(unittest.TestCase): ...@@ -151,7 +151,7 @@ class urlretrieveNetworkTests(unittest.TestCase):
with self.urlretrieve("http://www.python.org/") as (file_location, info): with self.urlretrieve("http://www.python.org/") as (file_location, info):
self.assertTrue(os.path.exists(file_location), "file location returned by" self.assertTrue(os.path.exists(file_location), "file location returned by"
" urlretrieve is not a valid path") " urlretrieve is not a valid path")
with open(file_location, encoding='utf-8') as f: with open(file_location, 'rb') as f:
self.assertTrue(f.read(), "reading from the file location returned" self.assertTrue(f.read(), "reading from the file location returned"
" by urlretrieve failed") " by urlretrieve failed")
...@@ -161,7 +161,7 @@ class urlretrieveNetworkTests(unittest.TestCase): ...@@ -161,7 +161,7 @@ class urlretrieveNetworkTests(unittest.TestCase):
support.TESTFN) as (file_location, info): support.TESTFN) as (file_location, info):
self.assertEqual(file_location, support.TESTFN) self.assertEqual(file_location, support.TESTFN)
self.assertTrue(os.path.exists(file_location)) self.assertTrue(os.path.exists(file_location))
with open(file_location, encoding='utf-8') as f: with open(file_location, 'rb') as f:
self.assertTrue(f.read(), "reading from temporary file failed") self.assertTrue(f.read(), "reading from temporary file failed")
def test_header(self): def test_header(self):
...@@ -170,7 +170,7 @@ class urlretrieveNetworkTests(unittest.TestCase): ...@@ -170,7 +170,7 @@ class urlretrieveNetworkTests(unittest.TestCase):
self.assertIsInstance(info, email.message.Message, self.assertIsInstance(info, email.message.Message,
"info is not an instance of email.message.Message") "info is not an instance of email.message.Message")
logo = "http://www.python.org/community/logos/python-logo-master-v3-TM.png" logo = "http://www.python.org/static/community_logos/python-logo-master-v3-TM.png"
def test_data_header(self): def test_data_header(self):
with self.urlretrieve(self.logo) as (file_location, fileheaders): with self.urlretrieve(self.logo) as (file_location, fileheaders):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment