Merge pull request #3108 from kevinburke/flip-conditional

Flip conditional in session.send()
This commit is contained in:
Ian Cordasco
2016-04-21 10:30:22 -05:00
2 changed files with 9 additions and 1 deletions
+1 -1
View File
@@ -557,7 +557,7 @@ class Session(SessionRedirectMixin):
# It's possible that users might accidentally send a Request object.
# Guard against that specific failure case.
if not isinstance(request, PreparedRequest):
if isinstance(request, Request):
raise ValueError('You can only send PreparedRequests.')
# Set up variables needed for resolve_redirects and dispatching of hooks
+8
View File
@@ -638,6 +638,14 @@ class TestRequests:
resp = s.send(prep)
assert resp.status_code == 200
def test_non_prepared_request_error(self):
s = requests.Session()
req = requests.Request(u('POST'), '/')
with pytest.raises(ValueError) as e:
s.send(req)
assert str(e.value) == 'You can only send PreparedRequests.'
def test_custom_content_type(self, httpbin):
r = requests.post(
httpbin('post'),