mirror of
https://github.com/kennethreitz/requests.git
synced 2026-06-05 22:50:18 +00:00
Merge pull request #1503 from skastel/master
Fixing error return to be consistent with tuple return at the end of the method
This commit is contained in:
+4
-2
@@ -94,8 +94,10 @@ class RequestEncodingMixin(object):
|
||||
if parameters are supplied as a dict.
|
||||
|
||||
"""
|
||||
if (not files) or isinstance(data, str):
|
||||
return None
|
||||
if (not files):
|
||||
raise ValueError("Files must be provided.")
|
||||
elif isinstance(data, basestring):
|
||||
raise ValueError("Data must not be a string.")
|
||||
|
||||
new_fields = []
|
||||
fields = to_key_val_list(data or {})
|
||||
|
||||
@@ -10,6 +10,7 @@ import unittest
|
||||
import pickle
|
||||
|
||||
import requests
|
||||
import pytest
|
||||
from requests.auth import HTTPDigestAuth
|
||||
from requests.adapters import HTTPAdapter
|
||||
from requests.compat import str, cookielib, getproxies, urljoin, urlparse
|
||||
@@ -339,6 +340,12 @@ class RequestsTestCase(unittest.TestCase):
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
def test_conflicting_post_params(self):
|
||||
url = httpbin('post')
|
||||
with open('requirements.txt') as f:
|
||||
pytest.raises(ValueError, "requests.post(url, data='[{\"some\": \"data\"}]', files={'some': f})")
|
||||
pytest.raises(ValueError, "requests.post(url, data=u'[{\"some\": \"data\"}]', files={'some': f})")
|
||||
|
||||
def test_request_ok_set(self):
|
||||
r = requests.get(httpbin('status', '404'))
|
||||
self.assertEqual(r.ok, False)
|
||||
|
||||
Reference in New Issue
Block a user