Closed a0nguyen closed 3 years ago
hey @a0nguyen, I just tested locally and it seems to me the client actually need a list of tuples for headers, not a dictionary, so if you rewrite your test function as follows it should work:
def test_headers(client):
result = client.get(
'/',
headers=[('x-api-key', '12345')],
)
assert result.data == "Hello world!"
assert result.status == 200
I'm not sure this is documented correctly. I gonna keep this open until I investigated properly.
Hey @gi0baro
I've tried to pass headers to an emmett test clients, but I couldnt make it work.
Code sample: app.py
tests.py
Can you help me?
EDIT: here is the best workaround I've found using pytest-mock, but it's quite shady