From 372e01b09997e8148a2f7c3ce2a7c8f5d49b136c Mon Sep 17 00:00:00 2001 From: Pierre Gronlier Date: Wed, 26 Jun 2024 01:15:18 +0200 Subject: [PATCH] accept to overwrite sent headers when using TestClient --- blacksheep/testing/helpers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/blacksheep/testing/helpers.py b/blacksheep/testing/helpers.py index 7170d808..366e99c7 100644 --- a/blacksheep/testing/helpers.py +++ b/blacksheep/testing/helpers.py @@ -106,10 +106,13 @@ def get_example_scope( (b"connection", b"keep-alive"), (b"upgrade-insecure-requests", b"1"), ] - + ([tuple(header) for header in extra_headers] if extra_headers else []) + cookies_headers ) + headers = dict(headers) # convert sequence of tuple into dict + headers.update(dict(extra_headers) if extra_headers else {}) # overwrite previously defined header if any + headers = list(headers.items()) # convert dict to sequence of tuple + return { "type": scheme, "http_version": "1.1",