fix "py.cleanup -d" - add test and check to only remove empty dirs (!)
--HG-- branch : trunk
This commit is contained in:
parent
09ba42a1bb
commit
2b1505c0f3
|
@ -35,6 +35,7 @@ def main():
|
|||
if options.removedir:
|
||||
for x in path.visit(lambda x: x.check(dir=1),
|
||||
lambda x: x.check(dotfile=0, link=0)):
|
||||
if not x.listdir():
|
||||
remove(x, options)
|
||||
|
||||
def remove(path, options):
|
||||
|
|
|
@ -38,12 +38,14 @@ class TestPyCleanup:
|
|||
result = testdir.runpybin("py.cleanup", tmpdir)
|
||||
assert not pyc.check()
|
||||
|
||||
def test_dir_remove(self, testdir, tmpdir):
|
||||
p = tmpdir.mkdir("a")
|
||||
result = testdir.runpybin("py.cleanup", tmpdir)
|
||||
def test_dir_remove_simple(self, testdir, tmpdir):
|
||||
subdir = tmpdir.mkdir("subdir")
|
||||
p = subdir.ensure("file")
|
||||
result = testdir.runpybin("py.cleanup", "-d", tmpdir)
|
||||
assert result.ret == 0
|
||||
assert p.check()
|
||||
assert subdir.check()
|
||||
p.remove()
|
||||
p = tmpdir.mkdir("hello")
|
||||
result = testdir.runpybin("py.cleanup", tmpdir, '-d')
|
||||
assert result.ret == 0
|
||||
assert not p.check()
|
||||
|
||||
assert not subdir.check()
|
||||
|
|
Loading…
Reference in New Issue