Skip to content

Commit fd205c3

Browse files
committed
wreq: serve httpbin with gunicorn in the test command
test_send_async_bytes_stream, test_send_sync_bytes_stream and test_multiple_requests still failed on both legs after the test files were staged: the httpbin log shows each of their POSTs answered with a 501. Those tests send a streamed body, so the request goes out with Transfer-Encoding: chunked, and httpbin's before_request hook aborts any chunked request with 501 "Chunked requests are not supported" unless SERVER_SOFTWARE starts with gunicorn/. `python -m httpbin.core` runs it on the Werkzeug dev server, so it always takes that branch. Upstream's tests job runs httpbin from the kennethreitz/httpbin container, which serves it with gunicorn, so do the same here: install gunicorn (pure Python) next to httpbin and start httpbin:app with it on 127.0.0.1:8080. The gthread worker keeps keep-alive connections and concurrent requests working. Also correct the CIBW_TEST_SOURCES comment, which blamed the DecodingError on the missing files rather than on the 501.
1 parent f365442 commit fd205c3

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

‎.github/workflows/build-wreq.yml‎

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -96,17 +96,15 @@ jobs:
9696
PIP_EXTRA_INDEX_URL=https://pypi.riseproject.dev/simple/
9797
MATURIN_PEP517_ARGS="--features jemalloc"
9898
CARGO_BUILD_JOBS=2
99-
# Upstream's tests job serves httpbin on localhost:8080 as a service container.
100-
CIBW_TEST_REQUIRES: pytest pytest-asyncio pytest-rerunfailures httpbin
101-
# multipart_test.py, request_test.py and response_test.py open README.md,
102-
# Cargo.toml and LICENSE by a path relative to the repo root (e.g.
103-
# Path("./README.md"), open("README.md")) to build request bodies; without
104-
# them staged in test_cwd every such test fails with a FileNotFoundError,
105-
# surfaced as a DecodingError once that exception inside the async
106-
# body-stream leaves httpbin nothing to respond with.
99+
# Upstream's tests job serves httpbin on localhost:8080 from the kennethreitz/httpbin
100+
# container, i.e. under gunicorn: httpbin answers every chunked (streamed-body)
101+
# request with a 501 unless SERVER_SOFTWARE is gunicorn, so the Werkzeug dev
102+
# server behind `python -m httpbin.core` fails the body-stream tests.
103+
CIBW_TEST_REQUIRES: pytest pytest-asyncio pytest-rerunfailures httpbin gunicorn
104+
# The body-stream and multipart tests open these by a repo-root-relative path.
107105
CIBW_TEST_SOURCES: tests README.md Cargo.toml LICENSE
108106
CIBW_TEST_COMMAND: >-
109-
python -m httpbin.core --port 8080 > httpbin.log 2>&1 & HTTPBIN_PID=$!;
107+
python -m gunicorn -b 127.0.0.1:8080 -k gthread --threads 8 httpbin:app > httpbin.log 2>&1 & HTTPBIN_PID=$!;
110108
python -c "import wreq.wreq as m; assert m.__file__.endswith('.so'), m.__file__" &&
111109
for i in $(seq 60); do
112110
python -c "import urllib.request; urllib.request.urlopen('http://127.0.0.1:8080/get', timeout=2)" 2>/dev/null && break;

0 commit comments

Comments
 (0)