Skip to content
Myr

support request tuple data

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

rewrite the TestModels Ajust the code

authored by Feng Liu · committed by Feng Liu · parent 0303e9b · Browse files · 2 files+28 added−3 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+28 added−3 removed

  • other:+28 added−3 removed

2 files+28 added−3 removed

modified:requests/models.py+1 added-3 removed
406 unmodified lines
407 length = None408409 is_stream = all([410 hasattr(data, '__iter__'),411 not isinstance(data, basestring),412 not isinstance(data, list),413 not isinstance(data, dict)411 not isinstance(data, (basestring, list, tuple, dict))412 ])413414 try:415 length = super_len(data)
384 unmodified lines
modified:test_requests.py+27 added
19 unmodified lines
20from requests.exceptions import InvalidURL, MissingSchema21from requests.models import PreparedRequest, Response22from requests.structures import CaseInsensitiveDict23from requests.sessions import SessionRedirectMixin24from requests.models import PreparedRequest, urlencode25from requests.hooks import default_hooks2627try:28 import StringIO29except ImportError:
1246 unmodified lines
1276 TestRedirects.default_keyword_args)1277 assert session.calls[-1] == send_call127812791280@pytest.fixture1281def list_of_tuples():1282 return [1283 (('a', 'b'), ('c', 'd')),1284 (('c', 'd'), ('a', 'b')),1285 (('a', 'b'), ('c', 'd'), ('e', 'f')),1286 ]128712881289def test_data_argument_accepts_tuples(list_of_tuples):1290 """1291 Ensure that the data argument will accept tuples of strings1292 and properly encode them.1293 """1294 for data in list_of_tuples:1295 p = PreparedRequest()1296 p.prepare(1297 method='GET',1298 url='http://www.example.com',1299 data=data,1300 hooks=default_hooks()1301 )1302 assert p.body == urlencode(data)1303 13041305if __name__ == '__main__':1306 unittest.main()