Exemplo n.º 1
0
 def test_getitem_missing(self):
     pd = PersistentDict()
     with pytest.raises(KeyError):
         pd.getitem("abc")
     pd = pd.setitem("abc", 10)
     with pytest.raises(KeyError):
         pd.getitem("def")
Exemplo n.º 2
0
 def test_setitem_hash_collision(self):
     pd = PersistentDict().setitem(HashKey(0, "a"), 10).setitem(HashKey(0, "b"), 20).setitem(HashKey(0, "c"), 30).setitem(HashKey(0, "a"), 10)
     assert pd.getitem(HashKey(0, "a")) == 10
     assert pd.getitem(HashKey(0, "b")) == 20
     assert pd.getitem(HashKey(0, "c")) == 30
     with pytest.raises(KeyError):
         pd.getitem(HashKey(0, "d"))
Exemplo n.º 3
0
 def test_none_key(self):
     pd = PersistentDict()
     with pytest.raises(KeyError):
         pd.getitem(None)
     pd = pd.setitem(None, 3)
     assert pd.getitem(None) == 3
     pd = pd.setitem(None, 3)
     assert pd.getitem(None) == 3
     pd = pd.delitem(None)
     with pytest.raises(KeyError):
         pd.delitem(None)
Exemplo n.º 4
0
 def test_getitem(self):
     pd = PersistentDict()
     pd = pd.setitem("abc", 3)
     assert pd.getitem("abc") == 3
Exemplo n.º 5
0
 def test_setitem_same_value(self):
     pd = PersistentDict().setitem("abc", 3).setitem("abc", 3)
     assert pd.getitem("abc") == 3
Exemplo n.º 6
0
 def test_setitem_same_key(self):
     pd = PersistentDict().setitem("abc", 3).setitem("abc", 10)
     assert pd.getitem("abc") == 10
Exemplo n.º 7
0
 def test_setitem_same_key(self):
     pd = PersistentDict().setitem("abc", 3).setitem("abc", 10)
     assert pd.getitem("abc") == 10