From fade5763af3d03f076f3317589038201bbdeccaf Mon Sep 17 00:00:00 2001 From: Mikhail Korobov Date: Thu, 16 Feb 2017 02:02:50 +0500 Subject: [PATCH] TST more response.follow tests --- tests/test_http_response.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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'click me', + ) + self.assertRaisesRegexp(ValueError, 'no href', + resp.follow, resp.css('a')[0]) + def test_follow_whitespace_selector(self): resp = self.response_class( 'http://example.com',