Exemplo n.º 1
0
def test_ls_abominate():
    """recursive list of directory"""
    # setup
    mkdir('work')
    with cd('work'):
        d1 = to_path('d1')
        mkdir(d1)
        d1d1 = to_path('d1/d1')
        mkdir(d1d1)
        d1d2 = to_path('d1/d2')
        mkdir(d1d2)
        d1d1f1 = to_path('d1/d1/f1')
        touch(d1d1f1)
        d1d2f2 = to_path('d1/d2/f2')
        touch(d1d2f2)

        # run test
        paths = ls('.', select='**/*')

        # check
        assert set(str(f) for f in paths) == set(
            ['d1', 'd1/d1', 'd1/d2', 'd1/d1/f1', 'd1/d2/f2'])

    # cleanup
    rm('work')
Exemplo n.º 2
0
def test_ls_abominate():
    """recursive list of directory"""
    # setup
    mkdir("work")
    with cd("work"):
        d1 = to_path("d1")
        mkdir(d1)
        d1d1 = to_path("d1/d1")
        mkdir(d1d1)
        d1d2 = to_path("d1/d2")
        mkdir(d1d2)
        d1d1f1 = to_path("d1/d1/f1")
        touch(d1d1f1)
        d1d2f2 = to_path("d1/d2/f2")
        touch(d1d2f2)

        # run test
        paths = ls(".", select="**/*")

        # check
        assert set(str(f) for f in paths) == set(
            ["d1", "d1/d1", "d1/d2", "d1/d1/f1", "d1/d2/f2"])

    # cleanup
    rm("work")
Exemplo n.º 3
0
def test_ls_abominate():
    """recursive list of directory"""
    # setup
    mkdir('work')
    with cd('work'):
        d1 = to_path('d1')
        mkdir(d1)
        d1d1 = to_path('d1/d1')
        mkdir(d1d1)
        d1d2 = to_path('d1/d2')
        mkdir(d1d2)
        d1d1f1 = to_path('d1/d1/f1')
        touch(d1d1f1)
        d1d2f2 = to_path('d1/d2/f2')
        touch(d1d2f2)

        # run test
        paths = ls('.', select='**/*')

        # check
        assert set(str(f) for f in paths) == set(
           ['d1', 'd1/d1', 'd1/d2', 'd1/d1/f1', 'd1/d2/f2']
        )

    # cleanup
    rm('work')
Exemplo n.º 4
0
def test_chmod_gathering():
    """change mode of a multiple files"""
    # setup
    f1 = to_path('f1')
    f2 = to_path('f2')
    touch(f1, f2)

    # run test
    for i in range(8):
        chmod(i, f1, f2)
        # 0o100000 represents a regular file
        assert f1.stat().st_mode == 0o100000 + i
        assert getmod(f1) == i
        assert f2.stat().st_mode == 0o100000 + i
        assert getmod(f2) == i
        chmod(8 * i, f1, f2)
        assert f1.stat().st_mode == 0o100000 + 8 * i
        assert getmod(f1) == 8 * i
        assert f2.stat().st_mode == 0o100000 + 8 * i
        assert getmod(f2) == 8 * i
        chmod(8 * 8 * i, f1, f2)
        assert f1.stat().st_mode == 0o100000 + 8 * 8 * i
        assert f2.stat().st_mode == 0o100000 + 8 * 8 * i
        assert getmod(f1) == 8 * 8 * i
        assert getmod(f2) == 8 * 8 * i

    # cleanup
    rm(f1, f2)
Exemplo n.º 5
0
def initialize_configs(initialize):
    with cd(tests_dir):
        cp("CONFIGS", ".config/emborg")
        rm(".config/emborg/subdir")
        for p in lsf(".config/emborg"):
            contents = p.read_text()
            contents = contents.replace('⟪EMBORG⟫', emborg_dir)
            p.write_text(contents)
        touch(".config/.nobackup")
Exemplo n.º 6
0
def test_rm_downturn():
    """remove existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    rm(f1)

    # check
    assert not f1.exists()
Exemplo n.º 7
0
def test_rm_downturn():
    """remove existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    rm(f1)

    # check
    assert not f1.exists()
Exemplo n.º 8
0
def test_mkdir_cymbal():
    """attempt to make a directory over an existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    with pytest.raises(OSError):
        mkdir(f1)

    # cleanup
    rm(f1)
Exemplo n.º 9
0
def test_touch_endorse():
    """touch a new file"""
    # setup
    f1 = to_path("f1")

    # run test
    touch(f1)

    # check
    assert f1.is_file()

    # cleanup
    rm(f1)
Exemplo n.º 10
0
def test_touch_endorse():
    """touch a new file"""
    # setup
    f1 = to_path('f1')

    # run test
    touch(f1)

    # check
    assert f1.is_file()

    # cleanup
    rm(f1)
Exemplo n.º 11
0
def test_rm_ground():
    """remove two files"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    rm(f1, f2)

    # check
    assert not f1.exists()
    assert not f2.exists()
Exemplo n.º 12
0
def test_ln_ground():
    """link to a pre-existing name"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    with pytest.raises(OSError):
        ln(f1, f2)

    # cleanup
    rm(f1, f2)
Exemplo n.º 13
0
def test_rm_ground():
    """remove two files"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    rm(f1, f2)

    # check
    assert not f1.exists()
    assert not f2.exists()
Exemplo n.º 14
0
def test_touch_downturn():
    """touch an existing file"""
    # setup
    f1 = to_path("f1")
    touch(f1)

    # run test
    touch(f1)

    # check
    assert f1.is_file()

    # cleanup
    rm(f1)
Exemplo n.º 15
0
def test_ln_ground():
    """link to a pre-existing name"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    with pytest.raises(OSError):
        ln(f1, f2)

    # cleanup
    rm(f1, f2)
Exemplo n.º 16
0
def test_touch_downturn():
    """touch an existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    touch(f1)

    # check
    assert f1.is_file()

    # cleanup
    rm(f1)
Exemplo n.º 17
0
def test_mv_cymbal():
    """move two files to a new directory"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)
    d1 = to_path('d2')

    # run test
    with pytest.raises(OSError):
        mv(f1, f2, d1)

    # cleanup
    rm(f1, f2, d1)
Exemplo n.º 18
0
def test_mv_incense():
    """move two files into a nonexistent directory"""
    # setup
    d1 = to_path('d1')
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    with pytest.raises(OSError):
        mv([f1, f2], d1)

    # cleanup
    rm(d1, f1, f2)
Exemplo n.º 19
0
def test_cp_cymbal():
    """copy two files to a new directory"""
    # setup
    d1 = to_path('d1')
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    with pytest.raises(OSError):
        cp(f1, f2, d1)

    # cleanup
    rm(f1, f2, d1)
Exemplo n.º 20
0
def test_cp_dealer():
    """copy two files into a nonexistent directory"""
    # setup
    d1 = 'd1'
    f1 = 'f1'
    touch(f1)
    f2 = 'f2'
    touch(f2)

    # run test
    with pytest.raises(OSError):
        cp([f1, f2], d1)

    # cleanup
    rm(f1, f2)
Exemplo n.º 21
0
def test_cp_downturn():
    """copy file to new file"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')

    # run test
    cp(f1, f2)

    # check
    assert f2.is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 22
0
def test_cp_adieu():
    """copy two files to a new directory"""
    # setup
    d1 = 'd1'
    f1 = 'f1'
    touch(f1)
    f2 = 'f2'
    touch(f2)

    # run test
    with pytest.raises(OSError):
        cp(f1, f2, d1)

    # cleanup
    rm(f1, f2, d1)
Exemplo n.º 23
0
def test_cp_cymbal():
    """copy two files to a new directory"""
    # setup
    d1 = to_path("d1")
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    with pytest.raises(OSError):
        cp(f1, f2, d1)

    # cleanup
    rm(f1, f2, d1)
Exemplo n.º 24
0
def test_cp_dealer():
    """copy two files into a nonexistent directory"""
    # setup
    d1 = "d1"
    f1 = "f1"
    touch(f1)
    f2 = "f2"
    touch(f2)

    # run test
    with pytest.raises(OSError):
        cp([f1, f2], d1)

    # cleanup
    rm(f1, f2)
Exemplo n.º 25
0
def test_cp_demystify():
    """copy file to new file"""
    # setup
    f1 = "f1"
    touch(f1)
    f2 = "f2"

    # run test
    cp(f1, f2)

    # check
    assert to_path(f2).is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 26
0
def test_cp_demystify():
    """copy file to new file"""
    # setup
    f1 = 'f1'
    touch(f1)
    f2 = 'f2'

    # run test
    cp(f1, f2)

    # check
    assert to_path(f2).is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 27
0
def test_mv_cymbal():
    """move two files to a new directory"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)
    d1 = to_path("d2")

    # run test
    with pytest.raises(OSError):
        mv(f1, f2, d1)

    # cleanup
    rm(f1, f2, d1)
Exemplo n.º 28
0
def test_cp_incense():
    """copy two files into a nonexistent directory"""
    # setup
    d1 = to_path("d1")
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    with pytest.raises(OSError):
        cp([f1, f2], d1)

    # cleanup
    rm(f1, f2)
Exemplo n.º 29
0
def test_touch_cymbal():
    """touch multiple files"""
    # setup
    f1 = to_path("f1")
    f2 = to_path("f2")

    # run test
    touch([f1, f2])

    # check
    assert f1.is_file()
    assert f2.is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 30
0
def test_cp_adieu():
    """copy two files to a new directory"""
    # setup
    d1 = "d1"
    f1 = "f1"
    touch(f1)
    f2 = "f2"
    touch(f2)

    # run test
    with pytest.raises(OSError):
        cp(f1, f2, d1)

    # cleanup
    rm(f1, f2, d1)
Exemplo n.º 31
0
def test_touch_ground():
    """touch multiple files"""
    # setup
    f1 = to_path('f1')
    f2 = to_path('f2')

    # run test
    touch(f1, f2)

    # check
    assert f1.is_file()
    assert f2.is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 32
0
def test_touch_cymbal():
    """touch multiple files"""
    # setup
    f1 = to_path('f1')
    f2 = to_path('f2')

    # run test
    touch([f1, f2])

    # check
    assert f1.is_file()
    assert f2.is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 33
0
def test_cp_downturn():
    """copy file to new file"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")

    # run test
    cp(f1, f2)

    # check
    assert f2.is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 34
0
def test_cp_theorem():
    """copy file to existing file"""
    # setup
    f1 = 'f1'
    touch(f1)
    f2 = 'f2'
    touch(f2)

    # run test
    cp(f1, f2)

    # check
    assert to_path(f2).is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 35
0
def test_cp_gathering():
    """copy file into an existing directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    f1 = to_path('f1')
    touch(f1)

    # run test
    cp(f1, d1)

    # check
    assert to_path('d1/f1').is_file()

    # cleanup
    rm(d1)
Exemplo n.º 36
0
def test_rm_cymbal():
    """remove directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/f1')
    touch(d1f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    rm(d1, f2)

    # check
    assert not d1.exists()
    assert not f2.exists()
Exemplo n.º 37
0
def test_ls_narrow():
    """list files with select constraint"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    paths = ls(f1, f2, select="*2")

    # check
    assert set(str(f) for f in paths) == set(["f2"])

    # cleanup
    rm(f1, f2)
Exemplo n.º 38
0
def test_ls_rissole():
    """list files"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    paths = ls(f1, f2)

    # check
    assert set(str(f) for f in paths) == set(["f1", "f2"])

    # cleanup
    rm(f1, f2)
Exemplo n.º 39
0
def test_cp_endorse():
    """copy file to existing file"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    cp(f1, f2)

    # check
    assert f2.is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 40
0
def test_cp_endorse():
    """copy file to existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    cp(f1, f2)

    # check
    assert f2.is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 41
0
def test_lsd_rissole():
    """list files"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    files = lsd(f1, f2)

    # check
    assert set(str(f) for f in files) == set()

    # cleanup
    rm(f1, f2)
Exemplo n.º 42
0
def test_mv_downturn():
    """rename file"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')

    # run test
    mv(f1, f2)

    # check
    assert f2.is_file()
    assert not f1.exists()

    # cleanup
    rm(f1, f2)
Exemplo n.º 43
0
def test_cp_theorem():
    """copy file to existing file"""
    # setup
    f1 = "f1"
    touch(f1)
    f2 = "f2"
    touch(f2)

    # run test
    cp(f1, f2)

    # check
    assert to_path(f2).is_file()

    # cleanup
    rm(f1, f2)
Exemplo n.º 44
0
def test_lsd_rissole():
    """list files"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    files = lsd(f1, f2)

    # check
    assert set(str(f) for f in files) == set()

    # cleanup
    rm(f1, f2)
Exemplo n.º 45
0
def test_lsf_rissole():
    """list files"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    files = lsf(f1, f2)

    # check
    assert set(str(f) for f in files) == set(["f1", "f2"])

    # cleanup
    rm(f1, f2)
Exemplo n.º 46
0
def test_mv_downturn():
    """rename file"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")

    # run test
    mv(f1, f2)

    # check
    assert f2.is_file()
    assert not f1.exists()

    # cleanup
    rm(f1, f2)
Exemplo n.º 47
0
def test_lsf_narrow():
    """list files with select constraint"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    files = lsf(f1, f2, select='*2')

    # check
    assert set(str(f) for f in files) == set(['f2'])

    # cleanup
    rm(f1, f2)
Exemplo n.º 48
0
def test_lsf_rissole():
    """list files"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    files = lsf(f1, f2)

    # check
    assert set(str(f) for f in files) == set(['f1', 'f2'])

    # cleanup
    rm(f1, f2)
Exemplo n.º 49
0
def test_lsf_narrow():
    """list files with select constraint"""
    # setup
    f1 = to_path("f1")
    touch(f1)
    f2 = to_path("f2")
    touch(f2)

    # run test
    files = lsf(f1, f2, select="*2")

    # check
    assert set(str(f) for f in files) == set(["f2"])

    # cleanup
    rm(f1, f2)
Exemplo n.º 50
0
def test_rm_cymbal():
    """remove directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    d1f1 = to_path('d1/f1')
    touch(d1f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    rm(d1, f2)

    # check
    assert not d1.exists()
    assert not f2.exists()
Exemplo n.º 51
0
def test_ls_narrow():
    """list files with select constraint"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    paths = ls(f1, f2, select='*2')

    # check
    assert set(str(f) for f in paths) == set(['f2'])

    # cleanup
    rm(f1, f2)
Exemplo n.º 52
0
def test_ls_rissole():
    """list files"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    paths = ls(f1, f2)

    # check
    assert set(str(f) for f in paths) == set(['f1', 'f2'])

    # cleanup
    rm(f1, f2)
Exemplo n.º 53
0
def test_cp_gathering():
    """copy file into an existing directory"""
    # setup
    d1 = to_path("d1")
    mkdir(d1)
    f1 = to_path("f1")
    touch(f1)

    # run test
    cp(f1, d1)

    # check
    assert to_path("d1/f1").is_file()

    # cleanup
    rm(d1)
Exemplo n.º 54
0
def test_cp_convict():
    """copy directory into an nonexistent directory"""
    # setup
    d1 = 'd1'
    mkdir(d1)
    f1 = 'd1/f1'
    touch(f1)
    d2 = 'd2'

    # run test
    cp(d1, d2)

    # check
    assert to_path('d2/f1').is_file()

    # cleanup
    rm(d1, d2)
Exemplo n.º 55
0
def test_mv_endorse():
    """rename file, replacing existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)
    f2 = to_path('f2')
    touch(f2)

    # run test
    mv(f1, f2)

    # check
    assert f2.is_file()
    assert not f1.exists()

    # cleanup
    rm(f1, f2)
Exemplo n.º 56
0
def test_mv_gathering():
    """move file into an existing directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    f1 = to_path('f1')
    touch(f1)

    # run test
    mv(f1, d1)

    # check
    assert to_path('d1/f1').is_file()
    assert not f1.exists()

    # cleanup
    rm(d1, f1)
Exemplo n.º 57
0
def test_chmod_ground():
    """change mode of a single file"""
    # setup
    f1 = 'f1'
    touch(f1)

    # run test
    for i in range(8):
        chmod(i, f1)
        # 0o100000 represents a regular file
        assert to_path(f1).stat().st_mode == 0o100000 + i
        chmod(8*i, f1)
        assert to_path(f1).stat().st_mode == 0o100000 + 8*i
        chmod(8*8*i, f1)
        assert to_path(f1).stat().st_mode == 0o100000 + 8*8*i

    # cleanup
    rm(f1)
Exemplo n.º 58
0
def test_mv_swine():
    """rename directory"""
    # setup
    d1 = to_path('d1')
    mkdir(d1)
    f1 = to_path('d1/f1')
    touch(f1)
    d2 = to_path('d2')

    # run test
    mv(d1, d2)

    # check
    assert to_path('d2/f1').is_file()
    assert not d1.exists()

    # cleanup
    rm(d1, d2)