1
0
mirror of https://github.com/scrapy/scrapy.git synced 2025-02-24 05:45:31 +00:00

Change behavior to use method GET when there are unknown methods

in the form
This commit is contained in:
Claudio Salazar 2019-06-06 22:10:59 +02:00
parent 461682fc3d
commit 0c50879568
2 changed files with 5 additions and 4 deletions

View File

@ -52,7 +52,7 @@ class FormRequest(Request):
method = kwargs.pop('method', form.method).upper()
if method not in cls.valid_form_methods:
raise ValueError('Invalid form method in chosen form')
method = 'GET'
return cls(url=url, method=method, formdata=formdata, **kwargs)

View File

@ -1107,11 +1107,12 @@ class FormRequestTest(RequestTest):
for method in self.request_class.valid_form_methods:
response = _buildresponse(body % method)
r1 = self.request_class.from_response(response)
self.assertEqual(r1.method, method)
r = self.request_class.from_response(response)
self.assertEqual(r.method, method)
response = _buildresponse(body % 'UNKNOWN')
self.assertRaises(ValueError, self.request_class.from_response, response)
r = self.request_class.from_response(response)
self.assertEqual(r.method, 'GET')
def _buildresponse(body, **kwargs):