コード例 #1
0
ファイル: test_ls.py プロジェクト: vdo-lab/shlib
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')
コード例 #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")
コード例 #3
0
ファイル: test_ls.py プロジェクト: KenKundert/shlib
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')
コード例 #4
0
ファイル: test_chmod.py プロジェクト: vdo-lab/shlib
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)
コード例 #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")
コード例 #6
0
ファイル: test_rm.py プロジェクト: KenKundert/shlib
def test_rm_downturn():
    """remove existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    rm(f1)

    # check
    assert not f1.exists()
コード例 #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()
コード例 #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)
コード例 #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)
コード例 #10
0
ファイル: test_touch.py プロジェクト: KenKundert/shlib
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)
コード例 #11
0
ファイル: test_rm.py プロジェクト: KenKundert/shlib
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()
コード例 #12
0
ファイル: test_ln.py プロジェクト: KenKundert/shlib
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)
コード例 #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()
コード例 #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)
コード例 #15
0
ファイル: test_ln.py プロジェクト: KenKundert/shlib
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)
コード例 #16
0
ファイル: test_touch.py プロジェクト: KenKundert/shlib
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)
コード例 #17
0
ファイル: test_mv.py プロジェクト: KenKundert/shlib
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)
コード例 #18
0
ファイル: test_mv.py プロジェクト: vdo-lab/shlib
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)
コード例 #19
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #20
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #21
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #22
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #23
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #24
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #25
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #26
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #27
0
ファイル: test_mv.py プロジェクト: KenKundert/shlib
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)
コード例 #28
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #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)
コード例 #30
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #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)
コード例 #32
0
ファイル: test_touch.py プロジェクト: KenKundert/shlib
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)
コード例 #33
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #34
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #35
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #36
0
ファイル: test_rm.py プロジェクト: KenKundert/shlib
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()
コード例 #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)
コード例 #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)
コード例 #39
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #40
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #41
0
ファイル: test_lsd.py プロジェクト: KenKundert/shlib
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)
コード例 #42
0
ファイル: test_mv.py プロジェクト: KenKundert/shlib
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)
コード例 #43
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #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)
コード例 #45
0
ファイル: test_lsf.py プロジェクト: KenKundert/shlib
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)
コード例 #46
0
ファイル: test_mv.py プロジェクト: KenKundert/shlib
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)
コード例 #47
0
ファイル: test_lsf.py プロジェクト: vdo-lab/shlib
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)
コード例 #48
0
ファイル: test_lsf.py プロジェクト: vdo-lab/shlib
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)
コード例 #49
0
ファイル: test_lsf.py プロジェクト: KenKundert/shlib
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)
コード例 #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()
コード例 #51
0
ファイル: test_ls.py プロジェクト: KenKundert/shlib
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)
コード例 #52
0
ファイル: test_ls.py プロジェクト: KenKundert/shlib
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)
コード例 #53
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #54
0
ファイル: test_cp.py プロジェクト: KenKundert/shlib
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)
コード例 #55
0
ファイル: test_mv.py プロジェクト: KenKundert/shlib
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)
コード例 #56
0
ファイル: test_mv.py プロジェクト: KenKundert/shlib
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)
コード例 #57
0
ファイル: test_chmod.py プロジェクト: KenKundert/shlib
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)
コード例 #58
0
ファイル: test_mv.py プロジェクト: KenKundert/shlib
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)