#35851: django.test.client.ClientMixin._login doest not set enviorn like
REMOTE_ADDR can cause test failures in certain situations
-----------------------------------+--------------------------------------
Reporter: elonzh | Owner: (none)
Type: Bug | Status: new
Component: Testing framework | Version:
Severity: Normal | Resolution:
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------------+--------------------------------------
Description changed by elonzh:
Old description:
> Our service listens for the ''user_logged_in'' signal to log the user's
> IP information, but when using ''TestClient.login/force_login'', the
> absence of ''REMOTE_ADDR'' results in an error.
>
> By reviewing the source code, I found that
> ''TestClient.login/force_login''(https://github.com/django/django/blob/main/django/test/client.py#L869-L882)
> creates an empty HttpRequest, which behaves differently from
> ''django.test.client.Client.request''(https://github.com/django/django/blob/main/django/test/client.py#L401-L436).
>
> Therefore, I believe this is an issue that needs to be addressed.
New description:
Our service listens for the ''user_logged_in'' signal to log the user's IP
information, but when using ''TestClient.login/force_login'', the absence
of ''REMOTE_ADDR'' results in an error.
By reviewing the source code, I found that
''TestClient.login/force_login''(https://github.com/django/django/blob/main/django/test/client.py#L869-L882)
creates an empty HttpRequest, which behaves differently from
''django.test.client.Client.request''(https://github.com/django/django/blob/main/django/test/client.py#L401-L436).
Therefore, I believe this is an issue that needs to be addressed.
----
I'd like to create a patch if this ticket is confirmed.
--
--
Ticket URL: <https://code.djangoproject.com/ticket/35851#comment:1>
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/010701929f641b04-75dd233f-538d-4e5f-bc55-79d794308d19-000000%40eu-central-1.amazonses.com.