2
有没有方法可以测试测试客户端返回的response.context对象,RequestContext对象是?我检查了源代码,看起来他们将上下文包装在ContextList对象中。Django测试客户端:测试该上下文是否为RequestContext对象
有没有方法可以测试测试客户端返回的response.context对象,RequestContext对象是?我检查了源代码,看起来他们将上下文包装在ContextList对象中。Django测试客户端:测试该上下文是否为RequestContext对象
检查是否的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