当前位置: 首页>>代码示例>>Python>>正文


Python shlib.touch函数代码示例

本文整理汇总了Python中shlib.touch函数的典型用法代码示例。如果您正苦于以下问题:Python touch函数的具体用法?Python touch怎么用?Python touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了touch函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_ls_abominate

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')
开发者ID:KenKundert,项目名称:shlib,代码行数:26,代码来源:test_ls.py

示例2: test_rm_downturn

def test_rm_downturn():
    """remove existing file"""
    # setup
    f1 = to_path('f1')
    touch(f1)

    # run test
    rm(f1)

    # check
    assert not f1.exists()
开发者ID:KenKundert,项目名称:shlib,代码行数:11,代码来源:test_rm.py

示例3: test_mkdir_cymbal

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:12,代码来源:test_mkdir.py

示例4: test_touch_endorse

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:13,代码来源:test_touch.py

示例5: test_touch_downturn

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_touch.py

示例6: test_ln_ground

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_ln.py

示例7: test_rm_ground

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()
开发者ID:KenKundert,项目名称:shlib,代码行数:14,代码来源:test_rm.py

示例8: test_cp_dealer

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_cp.py

示例9: test_mv_cymbal

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_mv.py

示例10: test_touch_cymbal

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_touch.py

示例11: test_mv_incense

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_mv.py

示例12: test_cp_cymbal

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_cp.py

示例13: test_cp_downturn

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_cp.py

示例14: test_cp_adieu

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_cp.py

示例15: test_cp_demystify

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)
开发者ID:KenKundert,项目名称:shlib,代码行数:15,代码来源:test_cp.py


注:本文中的shlib.touch函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。