[Django] #30121: assertURLEqual() should coerce URLs built with reverse_lazy()

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[Django] #30121: assertURLEqual() should coerce URLs built with reverse_lazy()

Django
#30121: assertURLEqual() should coerce URLs built with reverse_lazy()
---------------------------------------------+------------------------
               Reporter:  Jon Dufresne       |          Owner:  nobody
                   Type:  Bug                |         Status:  new
              Component:  Testing framework  |        Version:  2.2
               Severity:  Release blocker    |       Keywords:
           Triage Stage:  Unreviewed         |      Has patch:  0
    Needs documentation:  0                  |    Needs tests:  0
Patch needs improvement:  0                  |  Easy pickings:  0
                  UI/UX:  0                  |
---------------------------------------------+------------------------
 Calling `assertRedirects()` now uses the new `assertURLEqual()`. If a URL
 is built with `reverse_lazy()`, `assertRedirects()` now results in the
 exception:

 {{{
 Traceback (most recent call last):
   ... # My project calls assertRedirects()
   File "django/django/test/testcases.py", line 383, in assertRedirects
     msg_prefix + "Response redirected to '%s', expected '%s'" % (url,
 expected_url)
   File "django/django/test/testcases.py", line 404, in assertURLEqual
     normalize(url1), normalize(url2),
   File "django/django/test/testcases.py", line 399, in normalize
     scheme, netloc, path, params, query, fragment = urlparse(url)
   File "/usr/lib64/python3.7/urllib/parse.py", line 367, in urlparse
     url, scheme, _coerce_result = _coerce_args(url, scheme)
   File "/usr/lib64/python3.7/urllib/parse.py", line 123, in _coerce_args
     return _decode_args(args) + (_encode_result,)
   File "/usr/lib64/python3.7/urllib/parse.py", line 107, in _decode_args
     return tuple(x.decode(encoding, errors) if x else '' for x in args)
   File "/usr/lib64/python3.7/urllib/parse.py", line 107, in <genexpr>
     return tuple(x.decode(encoding, errors) if x else '' for x in args)
 AttributeError: '__proxy__' object has no attribute 'decode'
 }}}

 This does not happen with Django 2.1. Bisected to commit
 24959e48d949a20be969f649ece3576dbc7ce422. A `reverse_lazy()` URL may be
 used as a class or module attribute to be reused by multiple tests
 methods.

 To solve this, the inner function in `assertURLequal()` can coerce the
 `url` argument using `str()`.

 https://github.com/django/django/blob/2.2a1/django/test/testcases.py#L394-L398

--
Ticket URL: <https://code.djangoproject.com/ticket/30121>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/052.b61130e5f579c9138ab9dcb9c87b5663%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30121: assertURLEqual() should coerce URLs built with reverse_lazy()

Django
#30121: assertURLEqual() should coerce URLs built with reverse_lazy()
-----------------------------------+--------------------------------------
     Reporter:  Jon Dufresne       |                    Owner:  nobody
         Type:  Bug                |                   Status:  new
    Component:  Testing framework  |                  Version:  2.2
     Severity:  Release blocker    |               Resolution:
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  1                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------
Changes (by Jon Dufresne):

 * has_patch:  0 => 1


Comment:

 [https://github.com/django/django/pull/10879 PR]

--
Ticket URL: <https://code.djangoproject.com/ticket/30121#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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.9b21e38c6088f33525e80e3c710d529c%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30121: assertURLEqual() should coerce URLs built with reverse_lazy()

Django
In reply to this post by Django
#30121: assertURLEqual() should coerce URLs built with reverse_lazy()
-----------------------------------+--------------------------------------
     Reporter:  Jon Dufresne       |                    Owner:  nobody
         Type:  Bug                |                   Status:  closed
    Component:  Testing framework  |                  Version:  2.2
     Severity:  Release blocker    |               Resolution:  fixed
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  1                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------
Changes (by Tim Graham <timograham@…>):

 * status:  new => closed
 * resolution:   => fixed


Comment:

 In [changeset:"d15c61cabbe1c15068ffeb58c64035057f0c7d5c" d15c61ca]:
 {{{
 #!CommitTicketReference repository=""
 revision="d15c61cabbe1c15068ffeb58c64035057f0c7d5c"
 Fixed #30121 -- Fixed assertURLEqual() crash with reverse_lazy() URLs.

 Regression in 24959e48d949a20be969f649ece3576dbc7ce422.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30121#comment:2>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.b7e0a3076a08c43a636b7efec760042a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [Django] #30121: assertURLEqual() should coerce URLs built with reverse_lazy()

Django
In reply to this post by Django
#30121: assertURLEqual() should coerce URLs built with reverse_lazy()
-----------------------------------+--------------------------------------
     Reporter:  Jon Dufresne       |                    Owner:  nobody
         Type:  Bug                |                   Status:  closed
    Component:  Testing framework  |                  Version:  2.2
     Severity:  Release blocker    |               Resolution:  fixed
     Keywords:                     |             Triage Stage:  Unreviewed
    Has patch:  1                  |      Needs documentation:  0
  Needs tests:  0                  |  Patch needs improvement:  0
Easy pickings:  0                  |                    UI/UX:  0
-----------------------------------+--------------------------------------

Comment (by Tim Graham <timograham@…>):

 In [changeset:"28fb4ed5d9fe541df6b2b0e93952c62bf0ce7962" 28fb4ed]:
 {{{
 #!CommitTicketReference repository=""
 revision="28fb4ed5d9fe541df6b2b0e93952c62bf0ce7962"
 [2.2.x] Fixed #30121 -- Fixed assertURLEqual() crash with reverse_lazy()
 URLs.

 Regression in 24959e48d949a20be969f649ece3576dbc7ce422.
 Backport of d15c61cabbe1c15068ffeb58c64035057f0c7d5c from master.
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30121#comment:3>
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 [hidden email].
To post to this group, send email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.9c146060b64c67cc9b8ff9bcf185984a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.