Exemplo n.º 1
0
 def test_open_unref_does_not_leak(self):
     temp_dir = testlib.temp_dir()
     env = lmdb.open(temp_dir)
     ref = weakref.ref(env)
     env = None
     testlib.debug_collect()
     assert ref() is None
Exemplo n.º 2
0
 def test_open_unref_does_not_leak(self):
     temp_dir = testlib.temp_dir()
     env = lmdb.open(temp_dir)
     ref = weakref.ref(env)
     env = None
     testlib.debug_collect()
     assert ref() is None
Exemplo n.º 3
0
 def test_weakref_callback_invoked_once(self):
     temp_dir = testlib.temp_dir()
     env = lmdb.open(temp_dir)
     env.close()
     count = [0]
     def callback(ref):
         count[0] += 1
     ref = weakref.ref(env, callback)
     env = None
     testlib.debug_collect()
     assert ref() is None
     assert count[0] == 1
Exemplo n.º 4
0
 def test_weakref_callback_invoked_once(self):
     temp_dir = testlib.temp_dir()
     env = lmdb.open(temp_dir)
     env.close()
     count = [0]
     def callback(ref):
         count[0] += 1
     ref = weakref.ref(env, callback)
     env = None
     testlib.debug_collect()
     assert ref() is None
     assert count[0] == 1
Exemplo n.º 5
0
 def test_open_close(self):
     temp_dir = testlib.temp_dir()
     env = lmdb.open(temp_dir)
     with env.begin() as txn:
         pass
     env.close()
     r1 = weakref.ref(env)
     r2 = weakref.ref(txn)
     env = None
     txn = None
     testlib.debug_collect()
     assert r1() is None
     assert r2() is None
Exemplo n.º 6
0
 def test_open_close(self):
     temp_dir = testlib.temp_dir()
     env = lmdb.open(temp_dir)
     with env.begin() as txn:
         pass
     env.close()
     r1 = weakref.ref(env)
     r2 = weakref.ref(txn)
     env = None
     txn = None
     testlib.debug_collect()
     assert r1() is None
     assert r2() is None