示例#1
0
def test_overwrite_fallback():
    d = DogmaticDict(fallback={'a': 23})
    d['a'] = 0
    assert d['a'] == 0
    assert list(d.keys()) == ['a']
    assert list(d.values()) == [0]
    assert list(d.items()) == [('a', 0)]
示例#2
0
def test_overwrite_fallback():
    d = DogmaticDict(fallback={'a': 23})
    d['a'] = 0
    assert d['a'] == 0
    assert list(d.keys()) == ['a']
    assert list(d.values()) == [0]
    assert list(d.items()) == [('a', 0)]
示例#3
0
def test_overwrite_fallback():
    d = DogmaticDict(fallback={"a": 23})
    d["a"] = 0
    assert d["a"] == 0
    assert list(d.keys()) == ["a"]
    assert list(d.values()) == [0]
    assert list(d.items()) == [("a", 0)]
示例#4
0
def test_dict_interface_set_item():
    d = DogmaticDict()
    d['a'] = 12
    d['b'] = 'foo'
    assert 'a' in d
    assert 'b' in d

    assert d['a'] == 12
    assert d['b'] == 'foo'

    assert set(d.keys()) == {'a', 'b'}
    assert set(d.values()) == {12, 'foo'}
    assert set(d.items()) == {('a', 12), ('b', 'foo')}
示例#5
0
def test_dict_interface_set_item():
    d = DogmaticDict()
    d['a'] = 12
    d['b'] = 'foo'
    assert 'a' in d
    assert 'b' in d

    assert d['a'] == 12
    assert d['b'] == 'foo'

    assert set(d.keys()) == {'a', 'b'}
    assert set(d.values()) == {12, 'foo'}
    assert set(d.items()) == {('a', 12), ('b', 'foo')}
示例#6
0
def test_dict_interface_set_item():
    d = DogmaticDict()
    d["a"] = 12
    d["b"] = "foo"
    assert "a" in d
    assert "b" in d

    assert d["a"] == 12
    assert d["b"] == "foo"

    assert set(d.keys()) == {"a", "b"}
    assert set(d.values()) == {12, "foo"}
    assert set(d.items()) == {("a", 12), ("b", "foo")}
示例#7
0
def test_dict_interface_initialized_empty():
    d = DogmaticDict()
    assert d == {}
    assert set(d.keys()) == set()
    assert set(d.values()) == set()
    assert set(d.items()) == set()
示例#8
0
def test_fallback_not_iterated():
    d = DogmaticDict(fallback={'a': 23})
    d['b'] = 1234
    assert list(d.keys()) == ['b']
    assert list(d.values()) == [1234]
    assert list(d.items()) == [('b', 1234)]
示例#9
0
def test_dict_interface_initialized_empty():
    d = DogmaticDict()
    assert d == {}
    assert set(d.keys()) == set()
    assert set(d.values()) == set()
    assert set(d.items()) == set()
示例#10
0
def test_fallback_not_iterated():
    d = DogmaticDict(fallback={'a': 23})
    d['b'] = 1234
    assert list(d.keys()) == ['b']
    assert list(d.values()) == [1234]
    assert list(d.items()) == [('b', 1234)]
示例#11
0
def test_fallback_not_iterated():
    d = DogmaticDict(fallback={"a": 23})
    d["b"] = 1234
    assert list(d.keys()) == ["b"]
    assert list(d.values()) == [1234]
    assert list(d.items()) == [("b", 1234)]