本文整理汇总了Python中shlib.touch函数的典型用法代码示例。如果您正苦于以下问题:Python touch函数的具体用法?Python touch怎么用?Python touch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了touch函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: test_mv_downturn
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)
开发者ID:KenKundert,项目名称:shlib,代码行数:16,代码来源:test_mv.py
示例17: test_rm_cymbal
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()
开发者ID:KenKundert,项目名称:shlib,代码行数:16,代码来源:test_rm.py
示例18: test_cp_gathering
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)
开发者ID:KenKundert,项目名称:shlib,代码行数:16,代码来源:test_cp.py
示例19: test_lsf_rissole
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)
开发者ID:KenKundert,项目名称:shlib,代码行数:16,代码来源:test_lsf.py
示例20: test_lsf_narrow
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)
开发者ID:KenKundert,项目名称:shlib,代码行数:16,代码来源:test_lsf.py
注:本文中的shlib.touch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论