Exemple #1
0
def test_touch():
    path = os.path.join(test_data_dir, 'touch')
    if exists(path):
        remove(path)
    ensure_dir(path)

    for file in ['a.txt', 'b.txt', 'c.txt']:
        touch(file, path=path)
    for file in ['a.txt', 'b.txt', 'c.txt']:
        assert exists(os.path.join(path, file))
    remove(path)
Exemple #2
0
def test_ensure_dir_inexisting():
    # make sure that inexisting does not yet exists
    inexisting = os.path.join(test_data_dir, 'inexisting')
    if exists(inexisting):
        remove(inexisting)
    assert not exists(inexisting)

    # make inexisting and check
    ensure_dir(inexisting)
    assert exists(inexisting)
    # clean up
    remove(inexisting)
    assert not exists(inexisting)
Exemple #3
0
def test_touch():
    path = os.path.join('data', 'touch')
    if exists(path, connection=leibniz1):
        remove(path, connection=leibniz1)
    ensure_dir(path, connection=leibniz1)

    for file in ['a.txt', 'b.txt', 'c.txt']:
        touch(file, path=path, connection=leibniz1)
    for file in ['a.txt', 'b.txt', 'c.txt']:
        p = os.path.join(path, file)
        assert exists(p, connection=leibniz1)

    remove(path, connection=leibniz1)
Exemple #4
0
def test_ensure_dir_inexisting():
    # make sure that inexisting does not yet exists
    inexisting = os.path.join('data', 'inexisting')
    if exists(inexisting, connection=leibniz1):
        remove(inexisting, connection=leibniz1)
    assert not exists(inexisting, connection=leibniz1)

    # make inexisting and check
    ensure_dir(inexisting, connection=leibniz1)

    assert exists(inexisting, connection=leibniz1)

    # clean up
    remove(inexisting, connection=leibniz1)
    assert not exists(inexisting, connection=leibniz1)
Exemple #5
0
def test_rename():
    # set up
    test_dir = os.path.join(test_data_dir, 'rename')
    ensure_dir(test_dir)
    old = os.path.join(test_dir, 'old.txt')
    touch(old)
    assert exists(old)

    # test
    new = os.path.join(test_dir, 'new.txt')
    rename(old, new)
    assert not exists(old)
    assert exists(new)

    # clean up
    remove(test_dir)
Exemple #6
0
def test_rename():
    # set up
    test_dir = os.path.join('data', 'rename')
    ensure_dir(test_dir, connection=leibniz1)
    old = os.path.join(test_dir, 'old.txt')
    touch(old, connection=leibniz1)
    assert exists(old, connection=leibniz1)

    # test
    new = os.path.join(test_dir, 'new.txt')
    rename(old, new, connection=leibniz1)
    assert not exists(old, connection=leibniz1)
    assert exists(new, connection=leibniz1)

    # clean up
    remove(test_dir, connection=leibniz1)
Exemple #7
0
def test_glob():
    path = os.path.join(test_data_dir, 'glob')
    if exists(path):
        remove(path)
    ensure_dir(path)
    files = ['a.txt', 'b.txt', 'c.txt', 'aa.txt']
    for file in files:
        touch(file, path=path)
    dirs = ['a.tx', 'd.txt']
    for folder in dirs:
        ensure_dir(os.path.join(path, folder))

    result = glob('*.txt', path=path)
    assert len(result) == 4
    for file in result:
        assert file in files

    result = glob('?.txt', path=path)
    assert len(result) == 3
    for file in result:
        assert file in files

    # clean up
    remove(path)
Exemple #8
0
def test_ensure_dir_existing():
    assert exists(test_data_dir)
    ensure_dir(test_data_dir)
    assert exists(test_data_dir)
Exemple #9
0
def test_ensure_dir_existing():
    assert exists('data', connection=leibniz1)
    ensure_dir('data', connection=leibniz1)
    assert exists('data', connection=leibniz1)