~abentley/bzrtools/bzrtools.dev

« back to all changes in this revision

Viewing changes to tests/clean_tree.py

  • Committer: Aaron Bentley
  • Date: 2007-06-12 22:09:44 UTC
  • mfrom: (540.1.2 bzrtools-0.17)
  • Revision ID: aaron.bentley@utoronto.ca-20070612220944-5zw4hlzp1ctq6mkl
Merge fixes from 0.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
from unittest import makeSuite
21
21
 
22
22
from bzrlib.bzrdir import BzrDir
23
 
try:
24
 
    from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
25
 
except ImportError:
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
29
25
 
 
26
from bzrlib.plugins.bzrtools.clean_tree import clean_tree, iter_deletables
30
27
 
31
28
class TestCleanTree(TestCaseInTempDir):
32
29
    def test_symlinks(self):
53
50
        finally:
54
51
            f.close()
55
52
        file('branch/file.BASE', 'wb').write('contents')
56
 
        self.assertEqual(len(list(iter_deletables(tree, unknown=True))), 1)
57
 
        file('branch/file', 'wb').write('contents')
58
 
        file('branch/file~', 'wb').write('contents')
59
 
        file('branch/file.pyc', 'wb').write('contents')
60
 
 
61
 
        dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
62
 
        assert sorted(['file', 'file.BASE']) == dels
63
 
 
64
 
        dels = [r for a,r in iter_deletables(tree, detritus=True)]
65
 
        assert sorted(['file~', 'file.BASE']) == dels
66
 
 
67
 
        dels = [r for a,r in iter_deletables(tree, ignored=True)]
68
 
        assert sorted(['file~', 'file.pyc', '.bzrignore']) == dels
69
 
 
70
 
        dels = [r for a,r in iter_deletables(tree, unknown=False)]
71
 
        assert [] == dels
 
53
        tree.lock_write()
 
54
        try:
 
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')
 
59
 
 
60
            dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
 
61
            assert sorted(['file', 'file.BASE']) == dels
 
62
 
 
63
            dels = [r for a,r in iter_deletables(tree, detritus=True)]
 
64
            assert sorted(['file~', 'file.BASE']) == dels
 
65
 
 
66
            dels = [r for a,r in iter_deletables(tree, ignored=True)]
 
67
            assert sorted(['file~', 'file.pyc', '.bzrignore']) == dels
 
68
 
 
69
            dels = [r for a,r in iter_deletables(tree, unknown=False)]
 
70
            assert [] == dels
 
71
        finally:
 
72
            tree.unlock()
72
73
 
73
74
def test_suite():
74
75
    return makeSuite(TestCleanTree)