开发者

Django Test Client: Test that context is a RequestContext object

is there a way to test that the response.context object the test client returns, a RequestContext object i开发者_JS百科s? I checked the source code and it seems they wrap the context in a ContextList object.


Check if the ContextList is not empty, then check the item which is a RequestContext object:

from django.template import RequestContext

response = client.post(...)
context_list = response.context

for context in context_list:
    if isinstance(context, RequestContext):
        # do some more test checks here
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜