def callback(port_id, delta): assert port_id in ports_to_update _t = Table(delta) _v = _t.view() assert _v.to_records() == unique_data[port] _v.delete() _t.delete()
def test_table_delete_callback(self, sentinel): s = sentinel(False) def callback(): s.set(True) data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}] tbl = Table(data) tbl.on_delete(callback) tbl.delete() assert s.get() is True
def test_table_delete_callback(self): sentinel = False def callback(): nonlocal sentinel sentinel = True data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}] tbl = Table(data) tbl.on_delete(callback) tbl.delete() assert sentinel == True
def test_table_delete(self): process = psutil.Process(os.getpid()) mem = process.memory_info().rss for x in range(10000): data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}] tbl = Table(data) tbl.delete() mem2 = process.memory_info().rss # assert 1 < (max2 / max) < 1.01 assert (mem2 - mem) < 2000000
def test_table_remove_delete_callback(self, sentinel): s = sentinel(False) def callback(): s.set(True) tbl = Table([{"a": 1}]) tbl.on_delete(callback) tbl.remove_delete(callback) tbl.delete() assert s.get() is False
def test_table_delete_with_view(self, sentinel): data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}] tbl = Table(data) process = psutil.Process(os.getpid()) mem = process.memory_info().rss for x in range(10000): view = tbl.view() view.delete() tbl.delete() mem2 = process.memory_info().rss assert (mem2 - mem) < 2000000
def test_table_remove_delete_callback(self): sentinel = False def callback(): nonlocal sentinel sentinel = True tbl = Table([{"a": 1}]) tbl.on_delete(callback) tbl.remove_delete(callback) tbl.delete() assert sentinel == False
def test_view_remove_delete_callback(self, sentinel): s = sentinel(False) def callback(): s.set(True) tbl = Table([{"a": 1}]) view = tbl.view() view.on_delete(callback) view.remove_delete(callback) view.delete() tbl.delete() assert s.get() is False
def test_view_remove_delete_callback(self): sentinel = False def callback(): nonlocal sentinel sentinel = True tbl = Table([{"a": 1}]) view = tbl.view() view.on_delete(callback) view.remove_delete(callback) view.delete() tbl.delete() assert sentinel == False
def test_table_delete_multiple_callback(self, sentinel): s1 = sentinel(False) s2 = sentinel(False) def callback1(): s1.set(True) def callback2(): s2.set(True) tbl = Table([{"a": 1}]) tbl.on_delete(callback1) tbl.on_delete(callback2) tbl.delete() assert s1.get() is True assert s2.get() is True
def test_table_delete_multiple_callback(self): sentinel1 = False sentinel2 = False def callback1(): nonlocal sentinel1 sentinel1 = True def callback2(): nonlocal sentinel2 sentinel2 = True tbl = Table([{"a": 1}]) tbl.on_delete(callback1) tbl.on_delete(callback2) tbl.delete() assert sentinel1 == True assert sentinel2 == True
def test_table_delete(self): data = [{"a": 1, "b": 2}, {"a": 3, "b": 4}] tbl = Table(data) tbl.delete()