Esempio n. 1
0
def test_defaultdictkey():
    d = recorder._defaultdictkey(lambda k: [str(k) + "k"])
    assert isinstance(d["abc"], list)
    assert 2 not in d
    d[1].append("hello")
    assert d[1] == ["1k", "hello"]
    d[1].append("bar")
    assert d[1] == ["1k", "hello", "bar"]
Esempio n. 2
0
def test_defaultdictkey_no_factory():
    d = recorder._defaultdictkey()
    with pytest.raises(KeyError):
        d[1]