Test failures if Brotli
is installed
#1618
Answered
by
Kludex
mgorny
asked this question in
Potential Issue
-
If To reproduce: $ python -m venv .venv
$ . .venv/bin/activate
$ pip install -r requirements.txt
[...]
$ pip install Brotli
Collecting Brotli
Using cached Brotli-1.0.9-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_12_x86_64.manylinux2010_x86_64.whl (2.7 MB)
Installing collected packages: Brotli
Successfully installed Brotli-1.0.9
$ pytest -v
========================================================= test session starts =========================================================
platform linux -- Python 3.10.4, pytest-7.1.2, pluggy-1.0.0 -- /tmp/starlette/.venv/bin/python
cachedir: .pytest_cache
rootdir: /tmp/starlette, configfile: setup.cfg
plugins: anyio-3.5.0
collected 568 items
[...]
============================================================== FAILURES ===============================================================
____________________________________________________ test_request_headers[asyncio] ____________________________________________________
test_client_factory = functools.partial(<class 'starlette.testclient.TestClient'>, backend='asyncio', backend_options={})
def test_request_headers(test_client_factory):
async def app(scope, receive, send):
request = Request(scope, receive)
headers = dict(request.headers)
response = JSONResponse({"headers": headers})
await response(scope, receive, send)
client = test_client_factory(app)
response = client.get("/", headers={"host": "example.org"})
> assert response.json() == {
"headers": {
"host": "example.org",
"user-agent": "testclient",
"accept-encoding": "gzip, deflate",
"accept": "*/*",
"connection": "keep-alive",
}
}
E AssertionError: assert {'headers': {...le.org', ...}} == {'headers': {...le.org', ...}}
E Differing items:
E {'headers': {'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'connection': 'keep-alive', 'host': 'example.org', ...}} != {'headers': {'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'host': 'example.org', ...}}
E Full diff:
E {
E 'headers': {'accept': '*/*',
E - 'accept-encoding': 'gzip, deflate',
E + 'accept-encoding': 'gzip, deflate, br',...
E
E ...Full output truncated (6 lines hidden), use '-vv' to show
tests/test_requests.py:48: AssertionError
_____________________________________________________ test_request_headers[trio] ______________________________________________________
test_client_factory = functools.partial(<class 'starlette.testclient.TestClient'>, backend='trio', backend_options={})
def test_request_headers(test_client_factory):
async def app(scope, receive, send):
request = Request(scope, receive)
headers = dict(request.headers)
response = JSONResponse({"headers": headers})
await response(scope, receive, send)
client = test_client_factory(app)
response = client.get("/", headers={"host": "example.org"})
> assert response.json() == {
"headers": {
"host": "example.org",
"user-agent": "testclient",
"accept-encoding": "gzip, deflate",
"accept": "*/*",
"connection": "keep-alive",
}
}
E AssertionError: assert {'headers': {...le.org', ...}} == {'headers': {...le.org', ...}}
E Differing items:
E {'headers': {'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'connection': 'keep-alive', 'host': 'example.org', ...}} != {'headers': {'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'host': 'example.org', ...}}
E Full diff:
E {
E 'headers': {'accept': '*/*',
E - 'accept-encoding': 'gzip, deflate',
E + 'accept-encoding': 'gzip, deflate, br',...
E
E ...Full output truncated (6 lines hidden), use '-vv' to show
tests/test_requests.py:48: AssertionError
___________________________________________________ test_websocket_headers[asyncio] ___________________________________________________
test_client_factory = functools.partial(<class 'starlette.testclient.TestClient'>, backend='asyncio', backend_options={})
def test_websocket_headers(test_client_factory):
async def app(scope: Scope, receive: Receive, send: Send) -> None:
websocket = WebSocket(scope, receive=receive, send=send)
headers = dict(websocket.headers)
await websocket.accept()
await websocket.send_json({"headers": headers})
await websocket.close()
client = test_client_factory(app)
with client.websocket_connect("/") as websocket:
expected_headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"connection": "upgrade",
"host": "testserver",
"user-agent": "testclient",
"sec-websocket-key": "testserver==",
"sec-websocket-version": "13",
}
data = websocket.receive_json()
> assert data == {"headers": expected_headers}
E AssertionError: assert {'headers': {...server', ...}} == {'headers': {...server', ...}}
E Differing items:
E {'headers': {'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'connection': 'upgrade', 'host': 'testserver', ...}} != {'headers': {'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'upgrade', 'host': 'testserver', ...}}
E Full diff:
E {
E 'headers': {'accept': '*/*',
E - 'accept-encoding': 'gzip, deflate',
E + 'accept-encoding': 'gzip, deflate, br',...
E
E ...Full output truncated (8 lines hidden), use '-vv' to show
tests/test_websockets.py:71: AssertionError
____________________________________________________ test_websocket_headers[trio] _____________________________________________________
test_client_factory = functools.partial(<class 'starlette.testclient.TestClient'>, backend='trio', backend_options={})
def test_websocket_headers(test_client_factory):
async def app(scope: Scope, receive: Receive, send: Send) -> None:
websocket = WebSocket(scope, receive=receive, send=send)
headers = dict(websocket.headers)
await websocket.accept()
await websocket.send_json({"headers": headers})
await websocket.close()
client = test_client_factory(app)
with client.websocket_connect("/") as websocket:
expected_headers = {
"accept": "*/*",
"accept-encoding": "gzip, deflate",
"connection": "upgrade",
"host": "testserver",
"user-agent": "testclient",
"sec-websocket-key": "testserver==",
"sec-websocket-version": "13",
}
data = websocket.receive_json()
> assert data == {"headers": expected_headers}
E AssertionError: assert {'headers': {...server', ...}} == {'headers': {...server', ...}}
E Differing items:
E {'headers': {'accept': '*/*', 'accept-encoding': 'gzip, deflate, br', 'connection': 'upgrade', 'host': 'testserver', ...}} != {'headers': {'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'upgrade', 'host': 'testserver', ...}}
E Full diff:
E {
E 'headers': {'accept': '*/*',
E - 'accept-encoding': 'gzip, deflate',
E + 'accept-encoding': 'gzip, deflate, br',...
E
E ...Full output truncated (8 lines hidden), use '-vv' to show
tests/test_websockets.py:71: AssertionError
======================================================= short test summary info =======================================================
XFAIL tests/middleware/test_base.py::test_contextvars[asyncio-CustomMiddlewareUsingBaseHTTPMiddleware]
BaseHTTPMiddleware creates a TaskGroup which copies the contextand erases any changes to it made within the TaskGroup
XFAIL tests/middleware/test_base.py::test_contextvars[trio-CustomMiddlewareUsingBaseHTTPMiddleware]
BaseHTTPMiddleware creates a TaskGroup which copies the contextand erases any changes to it made within the TaskGroup
SKIPPED [3] tests/conftest.py:11: Trio not supported (yet!)
======================================== 4 failed, 559 passed, 3 skipped, 2 xfailed in 40.59s ========================================= |
Beta Was this translation helpful? Give feedback.
Answered by
Kludex
May 3, 2022
Replies: 1 comment
-
Thanks for the report. Created #1618 from this discussion. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
mgorny
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the report. Created #1618 from this discussion.