Don't use urlopen in a with...as statement.

The urllib2.urlopen function under Python 2 does not return an
object which can be used as a context manager (no __enter__ or
__exit__ methods).
This commit is contained in:
Damien Goutte-Gattat
2019-08-07 18:57:05 +01:00
committed by Peter Cock
parent 4a4e755b87
commit 2a94b05706

View File

@ -279,9 +279,10 @@ class TestGckWithDGVC(unittest.TestCase):
return
try:
with urlopen('https://emb.carnegiescience.edu/sites/default/files/DGVC_GCK.zip') as response:
with open('Gck/DGVC_GCK.zip', 'wb') as f:
shutil.copyfileobj(response, f)
src = urlopen('https://emb.carnegiescience.edu/sites/default/files/DGVC_GCK.zip')
with open('Gck/DGVC_GCK.zip', 'wb') as dst:
shutil.copyfileobj(src, dst)
src.close()
except HTTPError:
self.skipTest("Cannot download the sample files")
return