def test_delitem_many(self):
     pd = PersistentDict()
     for i in xrange(25):
         pd = pd.setitem(i, i)
     with pytest.raises(KeyError):
         pd.delitem(26)
     for i in xrange(25):
         pd = pd.delitem(i)
     for i in xrange(25):
         assert i not in pd
 def test_delitem_many(self):
     pd = PersistentDict()
     for i in range(25):
         pd = pd.setitem(i, i)
     with pytest.raises(KeyError):
         pd.delitem(26)
     for i in range(25):
         pd = pd.delitem(i)
     for i in range(25):
         assert i not in pd
 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)
 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)
    def test_delitem(self):
        pd = PersistentDict()
        with pytest.raises(KeyError):
            pd.delitem("abc")
        pd = pd.setitem("abc", 3)
        pd = pd.delitem("abc")
        assert "abc" not in pd

        pd = PersistentDict().setitem(HashKey(0, "a"), 3).setitem(HashKey(0, "b"), 4)
        pd = pd.delitem(HashKey(0, "a")).delitem(HashKey(0, "b"))
        assert HashKey(0, "a") not in pd
        assert HashKey(0, "b") not in pd

        pd = PersistentDict().setitem("a", 1).setitem("b", 3).delitem("a")
        assert "a" not in pd
        assert "b" in pd
    def test_delitem(self):
        pd = PersistentDict()
        with pytest.raises(KeyError):
            pd.delitem("abc")
        pd = pd.setitem("abc", 3)
        pd = pd.delitem("abc")
        assert "abc" not in pd

        pd = PersistentDict().setitem(HashKey(0, "a"),
                                      3).setitem(HashKey(0, "b"), 4)
        pd = pd.delitem(HashKey(0, "a")).delitem(HashKey(0, "b"))
        assert HashKey(0, "a") not in pd
        assert HashKey(0, "b") not in pd

        pd = PersistentDict().setitem("a", 1).setitem("b", 3).delitem("a")
        assert "a" not in pd
        assert "b" in pd
 def test_setitem_many_collision(self):
     pd = PersistentDict()
     for i in xrange(25):
         pd = pd.setitem(HashKey(0, i), i)
     for i in xrange(25):
         assert HashKey(0, i) in pd
     for i in xrange(25):
         pd = pd.delitem(HashKey(0, i))
     assert len(pd) == 0
 def test_setitem_many_collision(self):
     pd = PersistentDict()
     for i in range(25):
         pd = pd.setitem(HashKey(0, i), i)
     for i in range(25):
         assert HashKey(0, i) in pd
     for i in range(25):
         pd = pd.delitem(HashKey(0, i))
     assert len(pd) == 0
 def test_delitem_hash_window_collision(self):
     pd = PersistentDict().setitem(HashKey(0x17, "a"), 2)
     with pytest.raises(KeyError):
         pd.delitem(HashKey(0x37, "b"))
 def test_delitem_hash_window_collision(self):
     pd = PersistentDict().setitem(HashKey(0x17, "a"), 2)
     with pytest.raises(KeyError):
         pd.delitem(HashKey(0x37, "b"))