--
Ticket URL: <https://code.djangoproject.com/ticket/16087>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_docs: => 0
* stage: Unreviewed => Design decision needed
* needs_tests: => 0
* needs_better_patch: => 0
Comment:
I think you're expected to use assertRedirects. Can't you just recover the
auto field and hash values by fetching the last object from the database?
If not, that's really an edge case, I'm not sure we want to modify Django
for this.
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:1>
Comment (by mrmachine):
`assertRedirects` tells me the URLs that were used in a chain of
redirects. It does not tell me the view (function or named URL) that was
executed for a given request. Unless I'm reading the docs wrong (in which
case this should be a doc fix), one of the goals of the test client is to
allow users to verify the view that was executed for a given request.
What I want to test is, what view function or named URL was executed to
generate the response for a given request. Not was an object created in
the database (and it may not always be), then perform a redundant URL
lookup (Django already did it when processing the request) so I can
finally test if the correct view function or named URL was executed.
It would be a lot easier to write and read tests (and DRY) to simply POST
your data to a URL, and verify the view function or named URL that
generated the response. Django works some magic to make available a list
of templatest that were used, the context, etc. Why not make the
ResolverMatch object available, too?
I had a +1 on making this possible from cramm on IRC. I'm happy to take a
crack at implementing this functionality OR writing a doc patch if that
ends up being the decision. I just don't want to work on a fix if the core
devs don't want it.
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:2>
* stage: Design decision needed => Accepted
Comment:
Since we have a +1 from a core developer, I'm going to accept the ticket.
If you want to discuss the idea further before implementing it, you can
send an email to django-developers.
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:3>
Comment (by aaugustin):
#15695 is related.
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
Closing this as fixed. Since #15695 was fixed, the resolver match object
is added to all requests (not only test client requests).
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:4>
* status: closed => reopened
* resolution: fixed =>
Comment:
Sorry, it must be too early in the morning. Got my requests and responses
mixed up!
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:5>
* owner: nobody => gchp
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:7>
* has_patch: 0 => 1
Comment:
Created PR for this issue: https://github.com/django/django/pull/2768
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"bf743a4d571bbb7da276bc21c61f6ada5d26942c"]:
{{{
#!CommitTicketReference repository=""
revision="bf743a4d571bbb7da276bc21c61f6ada5d26942c"
Fixed #16087 -- Added ResolverMatch instance to test client response.
Thanks mrmachine for the suggestion.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/16087#comment:9>