Doc suggestion. APIRequestFactory will not parse urlpatterns into view **kwargs. #9145
Unanswered
AngryChocobo
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
It raise a error when I write TestCase for detail page for django:
This is my test case
And this is my url define
Debug Normal Reqest
When I use debug, this line raise error:
I am confuse because when I use browser to request, it is ok.
So I follow the thread function call stack, I found **kwargs is {} when I run test and access
/user/1
but it will be{pk: 1}
when normal startserver. But django drf's docs doesn't say it need some specail conf for urlpatterns.But I think here must have some problem.
We can find
normal
request will resolve system url.After resolve url, it will magically let view have
{pk:1}
Debug Testing
It doesn't have url resolve step and directly into last step.
How to resolve this problem?
use rest_framework's APIClient
Afer this modify, the problem is resolved.
Now function call stack is very familiar and test case is success!
Beta Was this translation helpful? Give feedback.
All reactions