summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_urllib2.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-04-25 12:45:48 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2013-04-25 12:45:48 (GMT)
commit523809259251f5f2d3b7d1d291af850fd353b0eb (patch)
treec72e14cf1549f89eef8fafa08d84f27ca0d3a513 /Lib/test/test_urllib2.py
parent34373b22523302202345007ee685cc833a2b10e0 (diff)
downloadcpython-523809259251f5f2d3b7d1d291af850fd353b0eb.zip
cpython-523809259251f5f2d3b7d1d291af850fd353b0eb.tar.gz
cpython-523809259251f5f2d3b7d1d291af850fd353b0eb.tar.bz2
Issue #17272: Making the urllib.request's Request.full_url a descriptor. Fixes
bugs with assignment to full_url. Patch by Demian Brecht.
Diffstat (limited to 'Lib/test/test_urllib2.py')
-rw-r--r--Lib/test/test_urllib2.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_urllib2.py b/Lib/test/test_urllib2.py
index 089e04c..b4f940c 100644
--- a/Lib/test/test_urllib2.py
+++ b/Lib/test/test_urllib2.py
@@ -904,6 +904,30 @@ class HandlerTests(unittest.TestCase):
p_ds_req = h.do_request_(ds_req)
self.assertEqual(p_ds_req.unredirected_hdrs["Host"],"example.com")
+ def test_full_url_setter(self):
+ # Checks to ensure that components are set correctly after setting the
+ # full_url of a Request object
+
+ urls = [
+ 'http://example.com?foo=bar#baz',
+ 'http://example.com?foo=bar&spam=eggs#bash',
+ 'http://example.com',
+ ]
+
+ # testing a reusable request instance, but the url parameter is
+ # required, so just use a dummy one to instantiate
+ r = Request('http://example.com')
+ for url in urls:
+ r.full_url = url
+ self.assertEqual(r.get_full_url(), url)
+
+ def test_full_url_deleter(self):
+ r = Request('http://www.example.com')
+ del r.full_url
+ self.assertIsNone(r.full_url)
+ self.assertIsNone(r.fragment)
+ self.assertEqual(r.selector, '')
+
def test_fixpath_in_weirdurls(self):
# Issue4493: urllib2 to supply '/' when to urls where path does not
# start with'/'