Skip to content
Myr

Added test_chunked_upload to test_requests.py

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

authored by Braulio Valdivielso Martínez · committed by Braulio Valdivielso Martínez · parent f17ef75 · Browse files · 1 file+19 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

1 file+19 added−0 removed

  • tests:+19 added−0 removed

1 file+19 added−0 removed

modified:tests/test_requests.py+19 added
7 unmodified lines
8import os9import pickle10import collections11import contextlib12import threading1314import io15import requests16import pytest
10 unmodified lines
27from requests.structures import CaseInsensitiveDict28from requests.sessions import SessionRedirectMixin29from requests.models import urlencode30from requests.hooks import default_hooks31from testserver.server import Server32from .compat import StringIO, u3334# Requests to this URL should always fail with a connection timeout (nothing35# listening on that port)
1417 unmodified lines
14531454 with pytest.raises(ImportError):1455 from requests.packages import webbrowser14561457def test_chunked_upload():1458 """can safely send generators"""1459 block_server = threading.Event()1460 server = Server.basic_response_server(wait_to_close_event=block_server)1461 data = (i for i in [b'a', b'b', b'c']) 14621463 with server as (host, port):1464 url = 'http://{0}:{1}/'.format(host, port)1465 r = requests.post(url, data=data, stream=True)1466 block_server.set() # release server block14671468 assert r.status_code == 2001469 assert r.request.headers['Transfer-Encoding'] == 'chunked'1470147114721473147414751476if __name__ == '__main__':1477 unittest.main()