def test_kwargs_shadow_variables(self):
     mapping = LazyTemplateMapping({
         "a": "{{ var }}",
         "b": "{{ var }}"
     }, {"var": "var"},
                                   var="kwarg")
     assert mapping["a"] == "kwarg"
示例#2
0
 def test_items(self):
     mapping = LazyTemplateMapping({"a": "{{ var }}a", "b": "{{ var }}b"},
                                   {"var": "a"})
     assert set(mapping.items()) == set([("a", "aa"), ("b", "ab")])
示例#3
0
 def test_keys(self):
     mapping = LazyTemplateMapping({"a": "{{ var }}", "b": "{{ var }}"}, {})
     assert set(mapping.keys()) == set(["a", "b"])
示例#4
0
    def test_missing_key_error(self):
        mapping = LazyTemplateMapping({"key": "{{ var }}"}, {})

        with pytest.raises(KeyError):
            mapping['missing']
示例#5
0
 def test_single_key(self):
     mapping = LazyTemplateMapping({"key": "test", "err": "{{ var }}"},
                                   {"var": "a"})
     assert mapping["key"] == "test"
示例#6
0
 def test_not_templated_on_init(self):
     assert LazyTemplateMapping({"key": "{{ var }}"}, {})