Beispiel #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')
Beispiel #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")
Beispiel #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')
Beispiel #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)
Beispiel #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")
Beispiel #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()
Beispiel #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()
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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()
Beispiel #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)
Beispiel #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()
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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()
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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()
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)
Beispiel #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)