django.test.utils.ContextList - python examples

Here are the examples of the python api django.test.utils.ContextList taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

5 Examples 7

3 View Complete Implementation : client.py
Copyright GNU General Public License v2.0
Author : blackye
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))

3 View Complete Implementation : testcases.py
Copyright GNU General Public License v2.0
Author : blackye
    def __init__(self, test_case, template_name):
        self.test_case = test_case
        self.template_name = template_name
        self.rendered_templates = []
        self.rendered_template_names = []
        self.context = ContextList()

3 View Complete Implementation : client.py
Copyright MIT License
Author : bpgc-cte
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))

3 View Complete Implementation : client.py
Copyright MIT License
Author : rizwansoaib
def store_rendered_templates(store, signal, sender, template, context, **kwargs):
    """
    Store 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))

0 View Complete Implementation : snapshot.py
Copyright GNU General Public License v3.0
Author : evernote
@pytest.mark.parametrize('input, clean_output', [
    (None, None),
    ([], []),

    ({'foo': 'bar'}, {'foo': 'bar'}),
    ({'block': True, 'forloop': False, 'lastupdated': 1234}, {}),

    ([{'foo': 'bar'}], [{'foo': 'bar'}]),
    ([{'block': True}, {'forloop': False, 'lastupdated': 1234}], [{}, {}]),

    (ContextList([Context({'foo': 'bar'})]), {'foo': 'bar'}),
    (ContextList([Context({'block': True})]), {}),
    (ContextList([Context({'block': True}), Context({'foo': 'bar'})]),
     {'foo': 'bar'}),

    (RequestContext(None, {'foo': 'bar'}), {'foo': 'bar'}),
])
def test_snapshot_clean(input, clean_output):
    """Tests the cleanup of snapshot contexts."""
    snapshot = Snapshot('test')
    astert snapshot.clean(input) == clean_output