1. Marc Abramowitz
  2. sqlalchemy_msabramo_tox

Commits

Mike Bayer  committed 8562209

remove WeakIdentityMapping tests

  • Participants
  • Parent commits d9c3749
  • Branches default

Comments (0)

Files changed (1)

File test/base/test_utils.py

View file
  • Ignore whitespace
         assert (sym1 | sym2) & (sym2 | sym4)
 
 
-class WeakIdentityMappingTest(fixtures.TestBase):
-    class Data(object):
-        pass
-
-    def _some_data(self, some=20):
-        return [self.Data() for _ in xrange(some)]
-
-    def _fixture(self, some=20):
-        data = self._some_data()
-        wim = util.WeakIdentityMapping()
-        for idx, obj in enumerate(data):
-            wim[obj] = idx
-        return data, wim
-
-    def test_delitem(self):
-        data, wim = self._fixture()
-        needle = data[-1]
-
-        assert needle in wim
-        assert id(needle) in wim.by_id
-        eq_(wim[needle], wim.by_id[id(needle)])
-
-        del wim[needle]
-
-        assert needle not in wim
-        assert id(needle) not in wim.by_id
-        eq_(len(wim), (len(data) - 1))
-
-        data.remove(needle)
-
-        assert needle not in wim
-        assert id(needle) not in wim.by_id
-        eq_(len(wim), len(data))
-
-    def test_setitem(self):
-        data, wim = self._fixture()
-
-        o1, oid1 = data[-1], id(data[-1])
-
-        assert o1 in wim
-        assert oid1 in wim.by_id
-        eq_(wim[o1], wim.by_id[oid1])
-        id_keys = set(wim.by_id.keys())
-
-        wim[o1] = 1234
-        assert o1 in wim
-        assert oid1 in wim.by_id
-        eq_(wim[o1], wim.by_id[oid1])
-        eq_(set(wim.by_id.keys()), id_keys)
-
-        o2 = self.Data()
-        oid2 = id(o2)
-
-        wim[o2] = 5678
-        assert o2 in wim
-        assert oid2 in wim.by_id
-        eq_(wim[o2], wim.by_id[oid2])
-
-    def test_pop(self):
-        data, wim = self._fixture()
-        needle = data[-1]
-
-        needle = data.pop()
-        assert needle in wim
-        assert id(needle) in wim.by_id
-        eq_(wim[needle], wim.by_id[id(needle)])
-        eq_(len(wim), (len(data) + 1))
-
-        wim.pop(needle)
-        assert needle not in wim
-        assert id(needle) not in wim.by_id
-        eq_(len(wim), len(data))
-
-    def test_pop_default(self):
-        data, wim = self._fixture()
-        needle = data[-1]
-
-        value = wim[needle]
-        x = wim.pop(needle, 123)
-        ne_(x, 123)
-        eq_(x, value)
-        assert needle not in wim
-        assert id(needle) not in wim.by_id
-        eq_(len(data), (len(wim) + 1))
-
-        n2 = self.Data()
-        y = wim.pop(n2, 456)
-        eq_(y, 456)
-        assert n2 not in wim
-        assert id(n2) not in wim.by_id
-        eq_(len(data), (len(wim) + 1))
-
-    def test_popitem(self):
-        data, wim = self._fixture()
-        (needle, idx) = wim.popitem()
-
-        assert needle in data
-        eq_(len(data), (len(wim) + 1))
-        assert id(needle) not in wim.by_id
-
-    def test_setdefault(self):
-        data, wim = self._fixture()
-
-        o1 = self.Data()
-        oid1 = id(o1)
-
-        assert o1 not in wim
-
-        res1 = wim.setdefault(o1, 123)
-        assert o1 in wim
-        assert oid1 in wim.by_id
-        eq_(res1, 123)
-        id_keys = set(wim.by_id.keys())
-
-        res2 = wim.setdefault(o1, 456)
-        assert o1 in wim
-        assert oid1 in wim.by_id
-        eq_(res2, 123)
-        assert set(wim.by_id.keys()) == id_keys
-
-        del wim[o1]
-        assert o1 not in wim
-        assert oid1 not in wim.by_id
-        ne_(set(wim.by_id.keys()), id_keys)
-
-        res3 = wim.setdefault(o1, 789)
-        assert o1 in wim
-        assert oid1 in wim.by_id
-        eq_(res3, 789)
-        eq_(set(wim.by_id.keys()), id_keys)
-
-    def test_clear(self):
-        data, wim = self._fixture()
-
-        assert len(data) == len(wim) == len(wim.by_id)
-        wim.clear()
-
-        eq_(wim, {})
-        eq_(wim.by_id, {})
-
-    def test_update(self):
-        data, wim = self._fixture()
-        assert_raises(NotImplementedError, wim.update)
-
-    def test_weak_clear(self):
-        data, wim = self._fixture()
-
-        assert len(data) == len(wim) == len(wim.by_id)
-
-        del data[:]
-        gc_collect()
-
-        eq_(wim, {})
-        eq_(wim.by_id, {})
-        eq_(wim._weakrefs, {})
-
-    def test_weak_single(self):
-        data, wim = self._fixture()
-
-        assert len(data) == len(wim) == len(wim.by_id)
-
-        oid = id(data[0])
-        del data[0]
-        gc_collect()
-
-        assert len(data) == len(wim) == len(wim.by_id)
-        assert oid not in wim.by_id
-
-    def test_weak_threadhop(self):
-        data, wim = self._fixture()
-        data = set(data)
-
-        cv = threading.Condition()
-
-        def empty(obj):
-            cv.acquire()
-            obj.clear()
-            cv.notify()
-            cv.release()
-
-        th = threading.Thread(target=empty, args=(data,))
-
-        cv.acquire()
-        th.start()
-        cv.wait()
-        cv.release()
-        gc_collect()
-
-        eq_(wim, {})
-        eq_(wim.by_id, {})
-        eq_(wim._weakrefs, {})
 
 
 class TestFormatArgspec(fixtures.TestBase):