有没有办法测试测试客户端返回的response.context对象,RequestContext对象是?我检查了源代码,它似乎将上下文包装在ContextList对象中。
答案 0 :(得分:2)
检查ContextList是否为空,然后检查作为RequestContext
对象的项目:
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