Пример #1
0
async def test_storage_dir(tmpdir):
    root = RootAnalysis()
    assert root.storage_dir is None
    # use the default temp dir
    root.initialize_storage()
    assert root.storage_dir
    assert os.path.isdir(root.storage_dir)
    path = root.storage_dir
    await root.discard()
    assert root.storage_dir is None
    assert not os.path.isdir(path)

    # specify a temp dir
    path = str(tmpdir.mkdir("temp"))
    root = RootAnalysis()
    assert root.storage_dir is None
    root.initialize_storage(path)
    assert root.storage_dir == path
    assert os.path.exists(path)
    await root.discard()
    assert root.storage_dir is None
    assert not os.path.exists(path)

    # specify a temp dir that does not exist yet
    # we'll re-use the previous one
    root = RootAnalysis()
    assert root.storage_dir is None
    root.initialize_storage(path)  # does not currently exist
    assert root.storage_dir == path
    assert os.path.exists(path)
    await root.discard()
    assert root.storage_dir is None
    assert not os.path.exists(path)
Пример #2
0
def test_root_str():
    assert str(RootAnalysis())
    root = RootAnalysis()
    root.initialize_storage()
    assert str(root)