/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_clean_tree.py

  • Committer: John Arbash Meinel
  • Date: 2009-12-22 16:28:47 UTC
  • mto: This revision was merged to the branch mainline in revision 4922.
  • Revision ID: john@arbash-meinel.com-20091222162847-tvnsc69to4l4uf5r
Implement a permute_for_extension helper.

Use it for all of the 'simple' extension permutations.
It basically permutes all tests in the current module, by setting TestCase.module.
Which works well for most of our extension tests. Some had more advanced
handling of permutations (extra permutations, custom vars, etc.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2005, 2009 Canonical Ltd
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
#
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
#
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
16
 
 
17
 
 
18
import os
 
19
from StringIO import StringIO
 
20
 
 
21
from bzrlib.bzrdir import (
 
22
    BzrDir,
 
23
    )
 
24
from bzrlib.clean_tree import (
 
25
    clean_tree,
 
26
    iter_deletables,
 
27
    )
 
28
from bzrlib.osutils import (
 
29
    has_symlinks,
 
30
    )
 
31
from bzrlib.tests import (
 
32
    TestCaseInTempDir,
 
33
    )
 
34
 
 
35
 
 
36
class TestCleanTree(TestCaseInTempDir):
 
37
 
 
38
    def test_symlinks(self):
 
39
        if has_symlinks() is False:
 
40
            return
 
41
        os.mkdir('branch')
 
42
        BzrDir.create_standalone_workingtree('branch')
 
43
        os.symlink(os.path.realpath('no-die-please'), 'branch/die-please')
 
44
        os.mkdir('no-die-please')
 
45
        self.failUnlessExists('branch/die-please')
 
46
        os.mkdir('no-die-please/child')
 
47
 
 
48
        clean_tree('branch', unknown=True, no_prompt=True)
 
49
        self.failUnlessExists('no-die-please')
 
50
        self.failUnlessExists('no-die-please/child')
 
51
 
 
52
    def test_iter_deletable(self):
 
53
        """Files are selected for deletion appropriately"""
 
54
        os.mkdir('branch')
 
55
        tree = BzrDir.create_standalone_workingtree('branch')
 
56
        transport = tree.bzrdir.root_transport
 
57
        transport.put_bytes('.bzrignore', '*~\n*.pyc\n.bzrignore\n')
 
58
        transport.put_bytes('file.BASE', 'contents')
 
59
        tree.lock_write()
 
60
        try:
 
61
            self.assertEqual(len(list(iter_deletables(tree, unknown=True))), 1)
 
62
            transport.put_bytes('file', 'contents')
 
63
            transport.put_bytes('file~', 'contents')
 
64
            transport.put_bytes('file.pyc', 'contents')
 
65
            dels = sorted([r for a,r in iter_deletables(tree, unknown=True)])
 
66
            self.assertEqual(['file', 'file.BASE'], dels)
 
67
 
 
68
            dels = [r for a,r in iter_deletables(tree, detritus=True)]
 
69
            self.assertEqual(sorted(['file~', 'file.BASE']), dels)
 
70
 
 
71
            dels = [r for a,r in iter_deletables(tree, ignored=True)]
 
72
            self.assertEqual(sorted(['file~', 'file.pyc', '.bzrignore']),
 
73
                             dels)
 
74
 
 
75
            dels = [r for a,r in iter_deletables(tree, unknown=False)]
 
76
            self.assertEqual([], dels)
 
77
        finally:
 
78
            tree.unlock()