我们从Python开源项目中,提取了以下7个代码示例,用于说明如何使用django.test.utils.ContextList()。
def store_rendered_templates(store, signal, sender, template, context, **kwargs): """ Stores templates and contexts that are rendered. The context is copied so that it is an accurate representation at the time of rendering. """ store.setdefault('templates', []).append(template) store.setdefault('context', ContextList()).append(copy(context))
def clean(self, data): """Cleans up `data` before using it as a snapshot reference.""" if isinstance(data, RequestContext): return self.clean(data.flatten()) # XXX: maybe we can do something smarter than blacklisting when we # have a `ContextList`? elif isinstance(data, dict) or isinstance(data, ContextList): return { key: self.clean(data[key]) for key in data.keys() if key not in BLACKLISTED_KEYS } elif isinstance(data, list): return [self.clean(item) for item in data] return data
def store_rendered_templates(store, signal, sender, template, context, **kwargs): """ Stores templates and contexts that are rendered. The context is copied so that it is an accurate representation at the time of rendering. """ store.setdefault('templates', []).append(template) if 'context' not in store: store['context'] = ContextList() store['context'].append(copy(context))