20
20
from unittest import makeSuite
22
22
from bzrlib.bzrdir import BzrDir
24
from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
26
from bzrtools.clean_tree import clean_tree, iter_deletables
27
23
from bzrlib.osutils import has_symlinks
28
24
from bzrlib.tests import TestCaseInTempDir
26
from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
31
28
class TestCleanTree(TestCaseInTempDir):
32
29
def test_symlinks(self):
39
36
assert os.path.exists('branch/die-please')
40
37
os.mkdir('no-die-please/child')
39
clean_tree('branch', unknown=True)
43
40
assert os.path.exists('no-die-please')
44
41
assert os.path.exists('no-die-please/child')
55
52
file('branch/file.BASE', 'wb').write('contents')
56
self.assertEqual(len(list(iter_deletables(tree))), 1)
57
file('branch/file~', 'wb').write('contents')
58
file('branch/file.pyc', 'wb').write('contents')
59
dels = [r for a,r in iter_deletables(tree)]
60
assert 'file~' not in dels
61
assert 'file.pyc' not in dels
62
dels = [r for a,r in iter_deletables(tree, detritus=True)]
63
assert 'file~' in dels
64
assert 'file.pyc' not in dels
65
dels = [r for a,r in iter_deletables(tree, ignored=True)]
66
assert 'file~' in dels
67
assert 'file.BASE' in dels
68
assert 'file.pyc' in dels
69
dels = [r for a,r in iter_deletables(tree, unknown=False)]
70
assert 'file.BASE' not in dels
55
self.assertEqual(len(list(iter_deletables(tree, unknown=True))), 1)
56
file('branch/file', 'wb').write('contents')
57
file('branch/file~', 'wb').write('contents')
58
file('branch/file.pyc', 'wb').write('contents')
60
dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
61
assert sorted(['file', 'file.BASE']) == dels
63
dels = [r for a,r in iter_deletables(tree, detritus=True)]
64
assert sorted(['file~', 'file.BASE']) == dels
66
dels = [r for a,r in iter_deletables(tree, ignored=True)]
67
assert sorted(['file~', 'file.pyc', '.bzrignore']) == dels
69
dels = [r for a,r in iter_deletables(tree, unknown=False)]
73
75
return makeSuite(TestCleanTree)