Fix issue8582: urllib.urlretrieve fails with ValueError: Invalid format string
diff --git a/Lib/test/test_urllibnet.py b/Lib/test/test_urllibnet.py
index 8eb01e5..8cba2dc 100644
--- a/Lib/test/test_urllibnet.py
+++ b/Lib/test/test_urllibnet.py
@@ -7,6 +7,8 @@
import urllib
import sys
import os
+import time
+
mimetools = test_support.import_module("mimetools", deprecated=True)
@@ -178,6 +180,17 @@
self.assertIsInstance(header, mimetools.Message,
"header is not an instance of mimetools.Message")
+ def test_data_header(self):
+ logo = "http://www.python.org/community/logos/python-logo-master-v3-TM.png"
+ file_location, fileheaders = self.urlretrieve(logo)
+ os.unlink(file_location)
+ datevalue = fileheaders.getheader('Date')
+ dateformat = '%a, %d %b %Y %H:%M:%S GMT'
+ try:
+ time.strptime(datevalue, dateformat)
+ except ValueError:
+ self.fail('Date value not in %r format', dateformat)
+
def test_main():