Exemplo n.º 1
0
def test_database_reloading(db_dir):
    test_db = DB(db_dir, create_if_missing=True)
    c1 = test_db.collection('test')
    c1.append(5)
    c1.append(6)

    c1.delete(0)

    test_db.close()

    test_db2 = DB(db_dir)
    assert test_db2.collection('test')[0] == 6
    assert len(test_db2.collection('test')) == 1
Exemplo n.º 2
0
def collection(request):
    path = tempfile.mkdtemp()
    db = DB(path, create_if_missing=True)

    collection = db.collection('test')

    def finalize():
        db.close()
        shutil.rmtree(path)

    request.addfinalizer(finalize)
    return collection