#28703: URL regex for admin's app_index view isn't constructed deterministically
-------------------------------------+-------------------------------------
     Reporter:  erikbryant           |                    Owner:  nobody
         Type:                       |                   Status:  new
  Cleanup/optimization               |
    Component:  contrib.admin        |                  Version:  1.11
     Severity:  Normal               |               Resolution:
     Keywords:  stable               |             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):

 * type:  Uncategorized => Cleanup/optimization


Old description:

> https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L277
>
> The regex pattern that is constructed for an endpoint is not stable. For
> instance, in my project I have seen it construct each of the following:
>
> ^admin/^(?P<app_label>social_django|authtoken|queues|jobs|files|users|clusters|appps|auth|vdcs)/$
> ^admin/^(?P<app_label>social_django|auth|users|vdcs|appps|jobs|queues|authtoken|clusters|files)/$
> ^admin/^(?P<app_label>authtoken|appps|social_django|clusters|users|queues|jobs|vdcs|auth|files)/$
> ^admin/^(?P<app_label>authtoken|appps|social_django|clusters|users|queues|vdcs|jobs|auth|files)/$
>
> This precludes the use of patterns in unit tests.
>
> https://github.com/django/django/pull/9230

New description:

 https://github.com/django/django/blob/master/django/contrib/admin/sites.py#L277

 The regex pattern that is constructed for an endpoint is not stable. For
 instance, in my project I have seen it construct each of the following:
 {{{
 
^admin/^(?P<app_label>social_django|authtoken|queues|jobs|files|users|clusters|appps|auth|vdcs)/$
 
^admin/^(?P<app_label>social_django|auth|users|vdcs|appps|jobs|queues|authtoken|clusters|files)/$
 
^admin/^(?P<app_label>authtoken|appps|social_django|clusters|users|queues|jobs|vdcs|auth|files)/$
 
^admin/^(?P<app_label>authtoken|appps|social_django|clusters|users|queues|vdcs|jobs|auth|files)/$
 }}}
 This precludes the use of patterns in unit tests.

 https://github.com/django/django/pull/9230

--

Comment:

 It seems to me that such a URL introspection test in your project is
 testing an internal implementation in Django that could be subject to
 change in the future. Can you give an idea of what regressions you're
 looking to test for? I wonder if a test that inspects `_registry` (or
 perhaps better yet, uses the `site.is_registered()` method) would be more
 appropriate.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/28703#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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/068.37362a2719ed87044adc53562cd6dcc7%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to