﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35247	Test Client constructor accepts headers that are ignored/overwitten	Paul Garner	nobody	"At first glance it seems like you could supply 'default' headers that are applied to every request when instantiating a test Client...

{{{
class Client(ClientMixin, RequestFactory):
    def __init__(
        self,
        enforce_csrf_checks=False,
        raise_request_exception=True,
        *,
        headers=None,
        query_params=None,
        **defaults,
    ):
        super().__init__(headers=headers, query_params=query_params, **defaults)
        self.handler = ClientHandler(enforce_csrf_checks)
        self.raise_request_exception = raise_request_exception
        self.exc_info = None
        self.extra = None
        self.headers = None
}}}
https://github.com/django/django/blob/main/django/test/client.py#L1059

However passing `headers` arg is completely useless, because the request methods do this:

{{{
    def get(
        self,
        path,
        data=None,
        follow=False,
        secure=False,
        *,
        headers=None,
        query_params=None,
        **extra,
    ):
        """"""Request a response from the server using GET.""""""
        self.extra = extra
        self.headers = headers
        response = super().get(
            path,
            data=data,
            secure=secure,
            headers=headers,
            query_params=query_params,
            **extra,
        )
}}}
https://github.com/django/django/blob/main/django/test/client.py#L1121

This seems like a bad design?  Shouldn't the `get` etc methods merge their arg `headers` with `self.headers` without overwriting it? (and same for `extra`)

I'm happy to submit a PR for this, assuming things aren't the way they are for some necessary reason that I've missed.
"	Uncategorized	closed	Testing framework	5.0	Normal	invalid			Unreviewed	0	0	0	0	0	0
