-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
I'm testing a starlette app, let's pretend it's httpbin:
async def test_no_auth(client, services):
r = client.get("/bearer")
assert r.status_code == 401
assert r.headers == {
"access-control-allow-origin": "*",
"access-control-allow-methods": "*",
"access-control-max-age": "86400",
"content-type": ANY,
"x-content-type-options": ANY,
} This fails with E AttributeError: '_ANY' object has no attribute 'encode'
For now I work around this by "casting" the magic header dict to an actual dict:
async def test_no_auth(client, services):
r = client.get("/bearer")
assert r.status_code == 401
assert dict(r.headers) == {
"access-control-allow-origin": "*",
"access-control-allow-methods": "*",
"access-control-max-age": "86400",
"content-type": ANY,
"x-content-type-options": ANY,
} Then the comparison works and test is happy.
Metadata
Metadata
Assignees
Labels
No labels