mirror of https://github.com/scrapy/scrapy.git
no need for MultipleElementsFound exception. #111
This commit is contained in:
parent
ee1f7847a4
commit
2904dc2dc0
|
|
@ -13,10 +13,6 @@ from scrapy.http.request import Request
|
|||
from scrapy.utils.python import unicode_to_str
|
||||
|
||||
|
||||
class MultipleElementsFound(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class FormRequest(Request):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
|
@ -124,8 +120,7 @@ def _get_clickable(clickdata, clickables, form):
|
|||
if len(el) == 1:
|
||||
return (el[0].name, el[0].value)
|
||||
elif len(el) > 1:
|
||||
raise MultipleElementsFound("Multiple elements found (%r) "
|
||||
"matching the criteria in clickdata: %r"
|
||||
% (el, clickdata))
|
||||
raise ValueError("Multiple elements found (%r) matching the criteria "
|
||||
"in clickdata: %r" % (el, clickdata))
|
||||
else:
|
||||
raise ValueError('No clickeable element matching clickdata')
|
||||
raise ValueError('No clickeable element matching clickdata: %r' % (clickdata,))
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ from cStringIO import StringIO
|
|||
from urlparse import urlparse
|
||||
|
||||
from scrapy.http import Request, FormRequest, XmlRpcRequest, Headers, HtmlResponse
|
||||
from scrapy.http.request.form import MultipleElementsFound
|
||||
|
||||
|
||||
class RequestTest(unittest.TestCase):
|
||||
|
|
@ -384,7 +383,7 @@ class FormRequestTest(RequestTest):
|
|||
</form>
|
||||
"""
|
||||
response = HtmlResponse("http://www.example.com/this/list.html", body=respbody)
|
||||
self.assertRaises(MultipleElementsFound,
|
||||
self.assertRaises(ValueError,
|
||||
self.request_class.from_response,
|
||||
response,
|
||||
clickdata={'type': 'submit'})
|
||||
|
|
|
|||
Loading…
Reference in New Issue