summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2011-10-16 15:54:44 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2011-10-16 15:54:44 (GMT)
commitde49d64dbcfb108e79a0e42f983ebc2df07219a0 (patch)
tree8ef0e223f4594aabbb62a28fde5dd7a436a0c714 /Lib/test/test_urllib.py
parentd8886fc831e16ab225f7e474751cc1a7b3cd01df (diff)
downloadcpython-de49d64dbcfb108e79a0e42f983ebc2df07219a0.zip
cpython-de49d64dbcfb108e79a0e42f983ebc2df07219a0.tar.gz
cpython-de49d64dbcfb108e79a0e42f983ebc2df07219a0.tar.bz2
Fix closes issue 1673007 urllib.request to support HEAD requests with a new method arg.
Diffstat (limited to 'Lib/test/test_urllib.py')
-rw-r--r--Lib/test/test_urllib.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/test_urllib.py b/Lib/test/test_urllib.py
index 77637a6..4e34ae5 100644
--- a/Lib/test/test_urllib.py
+++ b/Lib/test/test_urllib.py
@@ -1157,6 +1157,28 @@ class URLopener_Tests(unittest.TestCase):
# self.assertEqual(ftp.ftp.sock.gettimeout(), 30)
# ftp.close()
+class RequestTests(unittest.TestCase):
+ """Unit tests for urllib.request.Request."""
+
+ def test_default_values(self):
+ Request = urllib.request.Request
+ request = Request("http://www.python.org")
+ self.assertEqual(request.get_method(), 'GET')
+ request = Request("http://www.python.org", {})
+ self.assertEqual(request.get_method(), 'POST')
+
+ def test_with_method_arg(self):
+ Request = urllib.request.Request
+ request = Request("http://www.python.org", method='HEAD')
+ self.assertEqual(request.method, 'HEAD')
+ self.assertEqual(request.get_method(), 'HEAD')
+ request = Request("http://www.python.org", {}, method='HEAD')
+ self.assertEqual(request.method, 'HEAD')
+ self.assertEqual(request.get_method(), 'HEAD')
+ request = Request("http://www.python.org", method='GET')
+ self.assertEqual(request.get_method(), 'GET')
+ request.method = 'HEAD'
+ self.assertEqual(request.get_method(), 'HEAD')
def test_main():
@@ -1172,6 +1194,7 @@ def test_main():
Utility_Tests,
URLopener_Tests,
#FTPWrapperTests,
+ RequestTests,
)