Skip to content
Myr

Merge pull request #1119 from Lukasa/diags

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Better diagnostics when trying to send unprepared request

authored by Kenneth Reitz · committed by Kenneth Reitz · parents 03f6908, b0657cf · Browse files · 2 files+9 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+9 added−0 removed

  • other:+9 added−0 removed

2 files+9 added−0 removed

modified:requests/sessions.py+5 added
363 unmodified lines
364 return self.request('DELETE', url, **kwargs)365366 def send(self, request, **kwargs):367 """Send a given PreparedRequest."""368 # It's possible that users might accidentally send a Request object.369 # Guard against that specific failure case.370 if getattr(request, 'prepare', None):371 raise ValueError('You can only send PreparedRequests.')372373 # Set up variables needed for resolve_redirects and dispatching of374 # hooks375 allow_redirects = kwargs.pop('allow_redirects', True)376 req = kwargs.pop('req', None)
68 unmodified lines
modified:test_requests.py+4 added
339 unmodified lines
340 url = 'http://user:pass@complex.url.com/path?query=yes'341 self.assertEqual(('user', 'pass'),342 requests.utils.get_auth_from_url(url))343344 def test_cannot_send_unprepared_requests(self):345 r = requests.Request(url=HTTPBIN)346 self.assertRaises(ValueError, requests.Session().send, r)347348if __name__ == '__main__':349 unittest.main()