本文整理汇总了Python中shlib.rm函数的典型用法代码示例。如果您正苦于以下问题:Python rm函数的具体用法?Python rm怎么用?Python rm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rm函数的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')
示例2: test_rm_endorse
def test_rm_endorse():
"""remove nonexistent file"""
# setup
f1 = to_path('f1')
# run test
rm(f1)
# check
assert not f1.exists()
示例3: 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()
示例4: cleanup
def cleanup(self):
if self.vim:
self.vim.kill()
for each in cull([self.file1, self.file2, self.file3, self.file4]):
path = to_path(each)
dn = path.parent
fn = path.name
swpfile = to_path(dn, '.' + fn + '.swp')
try:
rm(swpfile)
except OSError as e:
error(os_error(e))
示例5: 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)
示例6: test_mkdir_solstice
def test_mkdir_solstice():
"""attempt to make a directory and it parent directories"""
# setup
d1d1 = to_path('d1/d1')
# run test
mkdir(d1d1)
# check
assert d1d1.is_dir()
# cleanup
rm(d1d1)
示例7: 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)
示例8: test_mkdir_downturn
def test_mkdir_downturn():
"""make a directory"""
# setup
d1 = to_path('d1')
# run test
mkdir(d1)
# check
assert d1.is_dir()
# cleanup
rm(d1)
示例9: 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()
示例10: 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)
示例11: test_mkdir_brain
def test_mkdir_brain():
"""attempt to make a directory over an existing directory"""
# setup
d1d1 = to_path('d1/d1')
mkdir(d1d1)
# run test
mkdir(d1d1)
# check
assert d1d1.is_dir()
# cleanup
rm(d1d1)
示例12: test_ln_endorse
def test_ln_endorse():
"""link a nonexistent file"""
# setup
f1 = to_path('f1')
f2 = to_path('f2')
# run test
ln(f1, f2)
# check
assert f2.is_symlink()
# cleanup
rm(f1, f2)
示例13: 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)
示例14: test_mkdir_gathering
def test_mkdir_gathering():
"""attempt to make a directory over an existing file"""
# setup
d1 = to_path('d1')
mkdir(d1)
# run test
mkdir(d1)
# check
assert d1.is_dir()
# cleanup
rm(d1)
示例15: test_mkdir_ground
def test_mkdir_ground():
"""make two directories"""
# setup
d1 = to_path('d1')
d2 = to_path('d2')
# run test
mkdir([d1, d2])
# check
assert d1.is_dir()
assert d2.is_dir()
# cleanup
rm(d1, d2)