def test_kwargs_shadow_variables(self): mapping = LazyTemplateMapping({ "a": "{{ var }}", "b": "{{ var }}" }, {"var": "var"}, var="kwarg") assert mapping["a"] == "kwarg"
def test_items(self): mapping = LazyTemplateMapping({"a": "{{ var }}a", "b": "{{ var }}b"}, {"var": "a"}) assert set(mapping.items()) == set([("a", "aa"), ("b", "ab")])
def test_keys(self): mapping = LazyTemplateMapping({"a": "{{ var }}", "b": "{{ var }}"}, {}) assert set(mapping.keys()) == set(["a", "b"])
def test_missing_key_error(self): mapping = LazyTemplateMapping({"key": "{{ var }}"}, {}) with pytest.raises(KeyError): mapping['missing']
def test_single_key(self): mapping = LazyTemplateMapping({"key": "test", "err": "{{ var }}"}, {"var": "a"}) assert mapping["key"] == "test"
def test_not_templated_on_init(self): assert LazyTemplateMapping({"key": "{{ var }}"}, {})