Skip to content

Scrapy, a fast high-level web crawling & scraping framework for Python.

TST more response.follow tests

Mikhail Korobovfade5763af3d
diff --git a/tests/test_http_response.py b/tests/test_http_response.py
index fa74b468b..924bb7979 100644
--- a/tests/test_http_response.py
+++ b/tests/test_http_response.py
@@ -414,11 +414,24 @@ class TextResponseTest(BaseResponseTest):
self.assertRaisesRegexp(ValueError, 'SelectorList',
resp.follow, resp.css('a'))
+ def test_follow_selector_invalid(self):
+ resp = self._links_response()
+ self.assertRaisesRegexp(ValueError, 'Unsupported',
+ resp.follow, resp.xpath('count(//div)')[0])
+
def test_follow_selector_attribute(self):
resp = self._links_response()
for src in resp.css('img::attr(src)'):
self._assert_followed_url(src, 'http://example.com/sample2.jpg')
+ def test_follow_selector_no_href(self):
+ resp = self.response_class(
+ url='http://example.com',
+ body=b'<html><body><a name=123>click me</a></body></html>',
+ )
+ self.assertRaisesRegexp(ValueError, 'no href',
+ resp.follow, resp.css('a')[0])
+
def test_follow_whitespace_selector(self):
resp = self.response_class(
'http://example.com',