예제 #1
0
def test_reuse(fn):
    """
    Test persistence of a LMDB() mapping.
    """
    with LMDB(fn) as z:
        assert len(z) == 0
        z["abc"] = b"123"

    with LMDB(fn) as z:
        assert len(z) == 1
        assert z["abc"] == b"123"
예제 #2
0
파일: test_lmdb.py 프로젝트: pradghos/zict
def test_reuse(fn):
    """
    Test persistence of a LMDB() mapping.
    """
    with LMDB(fn) as z:
        assert len(z) == 0
        z['abc'] = b'123'

    with LMDB(fn) as z:
        assert len(z) == 1
        assert z['abc'] == b'123'
예제 #3
0
파일: test_lmdb.py 프로젝트: mrocklin/zict
def test_file_descriptors_dont_leak(fn):
    psutil = pytest.importorskip('psutil')
    proc = psutil.Process()
    before = proc.num_fds()

    z = LMDB(fn)
    del z
    gc.collect()

    assert proc.num_fds() == before

    z = LMDB(fn)
    z.close()

    assert proc.num_fds() == before

    with LMDB(fn) as z:
        pass

    assert proc.num_fds() == before
예제 #4
0
def test_file_descriptors_dont_leak(fn):
    psutil = pytest.importorskip("psutil")
    proc = psutil.Process()
    before = proc.num_fds()

    z = LMDB(fn)
    del z
    gc.collect()

    assert proc.num_fds() == before

    z = LMDB(fn)
    z.close()

    assert proc.num_fds() == before

    with LMDB(fn) as z:
        pass

    assert proc.num_fds() == before
예제 #5
0
def test_creates_dir(fn):
    with LMDB(fn):
        assert os.path.isdir(fn)
예제 #6
0
def test_mapping(fn):
    """
    Test mapping interface for LMDB().
    """
    z = LMDB(fn)
    utils_test.check_mapping(z)