[py-svn] py-virtualenv commit b8da724503b5: fix "py.cleanup -d" - add test and check to only remove empty dirs (!)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Oct 27 16:23:42 CET 2009
# HG changeset patch -- Bitbucket.org
# Project py-virtualenv
# URL http://bitbucket.org/RonnyPfannschmidt/py-virtualenv/overview/
# User holger krekel <holger at merlinux.eu>
# Date 1256655794 -3600
# Node ID b8da724503b52dffac09cc6fa30ab6a71c6f92a2
# Parent 0c477e1fc2ffc220438af98fcac4c464c50a0bd7
fix "py.cleanup -d" - add test and check to only remove empty dirs (!)
--- a/_py/cmdline/pycleanup.py
+++ b/_py/cmdline/pycleanup.py
@@ -35,7 +35,8 @@ def main():
if options.removedir:
for x in path.visit(lambda x: x.check(dir=1),
lambda x: x.check(dotfile=0, link=0)):
- remove(x, options)
+ if not x.listdir():
+ remove(x, options)
def remove(path, options):
if options.dryrun:
--- a/testing/cmdline/test_cmdline.py
+++ b/testing/cmdline/test_cmdline.py
@@ -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()
More information about the pytest-commit
mailing list