问题描述
|
有没有一种方法可以测试测试客户端返回的response.context对象,RequestContext对象是?我检查了源代码,似乎它们将上下文包装在ContextList对象中。
解决方法
检查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