Scrapy, a fast high-level web crawling & scraping framework for Python.
PY3: Implement some attributes of WrappedRequest required in Python 3
orangain1f743996ff00
diff --git a/scrapy/http/cookies.py b/scrapy/http/cookies.pyindex e92c3fe73..a1e95102e 100644--- a/scrapy/http/cookies.py+++ b/scrapy/http/cookies.py@@ -137,13 +137,29 @@ class WrappedRequest(object):"""return self.request.meta.get('is_unverifiable', False)- # python3 uses request.unverifiable+ def get_origin_req_host(self):+ return urlparse_cached(self.request).hostname++ # python3 uses attributes instead of methods+ @property+ def full_url(self):+ return self.get_full_url()++ @property+ def host(self):+ return self.get_host()++ @property+ def type(self):+ return self.get_type()+@propertydef unverifiable(self):return self.is_unverifiable()- def get_origin_req_host(self):- return urlparse_cached(self.request).hostname+ @property+ def origin_req_host(self):+ return self.get_origin_req_host()def has_header(self, name):return name in self.request.headersdiff --git a/tests/test_http_cookies.py b/tests/test_http_cookies.pyindex d529f609b..549f779d8 100644--- a/tests/test_http_cookies.py+++ b/tests/test_http_cookies.py@@ -14,12 +14,15 @@ class WrappedRequestTest(TestCase):def test_get_full_url(self):self.assertEqual(self.wrapped.get_full_url(), self.request.url)+ self.assertEqual(self.wrapped.full_url, self.request.url)def test_get_host(self):self.assertEqual(self.wrapped.get_host(), urlparse(self.request.url).netloc)+ self.assertEqual(self.wrapped.host, urlparse(self.request.url).netloc)def test_get_type(self):self.assertEqual(self.wrapped.get_type(), urlparse(self.request.url).scheme)+ self.assertEqual(self.wrapped.type, urlparse(self.request.url).scheme)def test_is_unverifiable(self):self.assertFalse(self.wrapped.is_unverifiable())@@ -32,6 +35,7 @@ class WrappedRequestTest(TestCase):def test_get_origin_req_host(self):self.assertEqual(self.wrapped.get_origin_req_host(), 'www.example.com')+ self.assertEqual(self.wrapped.origin_req_host, 'www.example.com')def test_has_header(self):self.assertTrue(self.wrapped.has_header('content-type'))