#34240: assertRedirects() doesn't preserve headers set in RequestFactory/Client
methods.
-----------------------------------+------------------------------------
     Reporter:  Mariusz Felisiak   |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  dev
     Severity:  Release blocker    |               Resolution:
     Keywords:                     |             Triage Stage:  Accepted
    Has patch:  0                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+------------------------------------
Description changed by Mariusz Felisiak:

Old description:

> Similar to the #28337, HTTP headers are no longer in `extra` so they are
> no longer preserved in `assertRedirects()`.
>
> {{{#!diff
> diff --git a/tests/test_client_regress/tests.py
> b/tests/test_client_regress/tests.py
> index aaf25e2ec4..53cdc3bf07 100644
> --- a/tests/test_client_regress/tests.py
> +++ b/tests/test_client_regress/tests.py
> @@ -613,6 +613,18 @@ class AssertRedirectsTests(SimpleTestCase):
>                      status_code=302,
>                      target_status_code=302,
>                  )
> +                response = req_method(
> +                    "/redirect_based_on_extra_headers_1/",
> +                    follow=False,
> +                    headers={"redirect": "val"},
> +                )
> +                self.assertRedirects(
> +                    response,
> +                    "/redirect_based_on_extra_headers_2/",
> +                    fetch_redirect_response=True,
> +                    status_code=302,
> +                    target_status_code=302,
> +                )
>

>  @override_settings(ROOT_URLCONF="test_client_regress.urls")
> }}}
>
> Bug in 67da22f08e05018ea968fcacbac9ac37ea925d85.

New description:

 Similar to the #28337, HTTP headers can be passed in the `headers`
 argument and should be preserved in `assertRedirects()`.

 {{{#!diff
 diff --git a/tests/test_client_regress/tests.py
 b/tests/test_client_regress/tests.py
 index aaf25e2ec4..53cdc3bf07 100644
 --- a/tests/test_client_regress/tests.py
 +++ b/tests/test_client_regress/tests.py
 @@ -613,6 +613,18 @@ class AssertRedirectsTests(SimpleTestCase):
                      status_code=302,
                      target_status_code=302,
                  )
 +                response = req_method(
 +                    "/redirect_based_on_extra_headers_1/",
 +                    follow=False,
 +                    headers={"redirect": "val"},
 +                )
 +                self.assertRedirects(
 +                    response,
 +                    "/redirect_based_on_extra_headers_2/",
 +                    fetch_redirect_response=True,
 +                    status_code=302,
 +                    target_status_code=302,
 +                )


  @override_settings(ROOT_URLCONF="test_client_regress.urls")
 }}}

 Bug in 67da22f08e05018ea968fcacbac9ac37ea925d85.

--

-- 
Ticket URL: <https://code.djangoproject.com/ticket/34240#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701857c0e26b6-8d33827b-e760-4491-a7d5-4b6eb8c3cca3-000000%40eu-central-1.amazonses.com.

Reply via email to