Scrapy, a fast high-level web crawling & scraping framework for Python.
Added test case to make sure that ambiguous clickdata is not allowed
Lucian Ursudf2e79527837
diff --git a/scrapy/tests/test_http_request.py b/scrapy/tests/test_http_request.pyindex 8765070cc..091982742 100644--- a/scrapy/tests/test_http_request.py+++ b/scrapy/tests/test_http_request.py@@ -5,6 +5,7 @@ from cStringIO import StringIOfrom urlparse import urlparsefrom scrapy.http import Request, FormRequest, XmlRpcRequest, Headers, HtmlResponse+from scrapy.http.request.form import MultipleElementsFoundclass RequestTest(unittest.TestCase):@@ -320,6 +321,21 @@ class FormRequestTest(RequestTest):self.assertFalse('clickeable1' in urlargs, urlargs)self.assertFalse('clickeable2' in urlargs, urlargs)+ def test_from_response_ambiguous_clickdata(self):+ respbody = """+<form action="get.php" method="GET">+<input type="submit" name="clickeable1" value="clicked1">+<input type="hidden" name="one" value="1">+<input type="hidden" name="two" value="3">+<input type="submit" name="clickeable2" value="clicked2">+</form>+ """+ response = HtmlResponse("http://www.example.com/this/list.html", body=respbody)+ self.assertRaises(MultipleElementsFound,+ self.request_class.from_response,+ response,+ clickdata={'type': 'submit'})+def test_from_response_errors_noform(self):respbody = """<html></html>"""response = HtmlResponse("http://www.example.com/lala.html", body=respbody)