~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_workingtree.py

  • Committer: Marius Kruger
  • Date: 2007-04-11 22:53:48 UTC
  • mto: This revision was merged to the branch mainline in revision 2455.
  • Revision ID: amanic@gmail.com-20070411225348-7145vlsq3f390osg
* test_workingtree/TestRemove
  - Change global and local constants to class variables.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
        self.assertEqual(TreeLink().kind_character(), '')
64
64
 
65
65
 
66
 
files=['a','b/','b/c']
 
66
 
67
67
class TestRemove(TestCaseWithTransport):
68
68
    """Tests WorkingTree.remove"""
69
69
 
 
70
    files=['a','b/','b/c']
 
71
    b = ['b']
 
72
    b_c = ['b','b/c']
 
73
    
70
74
    def getTree(self):
71
75
        self.makeAndChdirToTestDir()
72
76
        tree = self.make_branch_and_tree('.')
73
 
        self.build_tree(files)
 
77
        self.build_tree(TestRemove.files)
74
78
        return tree
75
79
 
76
80
    def test_remove_unchanged_files(self):
77
81
        """check that unchanged files are removed and deleted."""
78
82
        tree = self.getTree()
79
 
        tree.add(files)
 
83
        tree.add(TestRemove.files)
80
84
        tree.commit("files must not have changes")
81
85
 
82
 
        self.assertInWorkingTree(files)
83
 
 
84
 
        tree.remove(files, keep_files=False)
85
 
 
86
 
        self.assertNotInWorkingTree(files)
87
 
        self.failIfExists(files)
 
86
        self.assertInWorkingTree(TestRemove.files)
 
87
 
 
88
        tree.remove(TestRemove.files, keep_files=False)
 
89
 
 
90
        self.assertNotInWorkingTree(TestRemove.files)
 
91
        self.failIfExists(TestRemove.files)
88
92
 
89
93
    def test_remove_changed_files(self):
90
94
        """check that changed files are removed but not deleted."""
91
95
        tree = self.getTree()
92
 
        tree.add(files)
93
 
        self.assertInWorkingTree(files)
94
 
 
95
 
        tree.remove(files, keep_files=False)
96
 
 
97
 
        self.assertNotInWorkingTree(files)
98
 
        self.failUnlessExists(files)
 
96
        tree.add(TestRemove.files)
 
97
        self.assertInWorkingTree(TestRemove.files)
 
98
 
 
99
        tree.remove(TestRemove.files, keep_files=False)
 
100
 
 
101
        self.assertNotInWorkingTree(TestRemove.files)
 
102
        self.failUnlessExists(TestRemove.files)
99
103
 
100
104
    def test_force_remove_changed_files(self):
101
105
        """check that changed files are removed and deleted when forced."""
102
106
        tree = self.getTree()
103
 
        tree.add(files)
104
 
        self.assertInWorkingTree(files)
105
 
 
106
 
        tree.remove(files, keep_files=False, force=True)
107
 
 
108
 
        self.assertNotInWorkingTree(files)
109
 
        self.failIfExists(files)
 
107
        tree.add(TestRemove.files)
 
108
        self.assertInWorkingTree(TestRemove.files)
 
109
 
 
110
        tree.remove(TestRemove.files, keep_files=False, force=True)
 
111
 
 
112
        self.assertNotInWorkingTree(TestRemove.files)
 
113
        self.failIfExists(TestRemove.files)
110
114
 
111
115
    def test_remove_nonexisting_files(self):
112
116
        """delete files which does not exist."""
113
117
        tree = self.getTree()
114
 
        tree.remove(files, keep_files=False)
 
118
        tree.remove(TestRemove.files, keep_files=False)
115
119
        tree.remove([''], keep_files=False)
116
 
        tree.remove(['b'], keep_files=False)
 
120
        tree.remove(TestRemove.b, keep_files=False)
117
121
 
118
122
    def test_remove_nonempty_directory(self):
119
123
        tree = self.getTree()
120
 
        tree.add(files)
 
124
        tree.add(TestRemove.files)
121
125
        tree.commit("make sure b is versioned")
122
 
        self.assertInWorkingTree(files)
123
 
        self.failUnlessExists(files)
124
 
        b = ['b']
125
 
        tree.remove(b, keep_files=False)
126
 
        self.assertNotInWorkingTree(b)
127
 
        self.failUnlessExists(b)
 
126
        self.assertInWorkingTree(TestRemove.files)
 
127
        self.failUnlessExists(TestRemove.files)
 
128
        tree.remove(TestRemove.b, keep_files=False)
 
129
        self.assertNotInWorkingTree(TestRemove.b)
 
130
        self.failUnlessExists(TestRemove.b)
128
131
 
129
132
    def test_force_remove_nonempty_directory(self):
130
133
        tree = self.getTree()
131
 
        tree.add(files)
 
134
        tree.add(TestRemove.files)
132
135
        tree.commit("make sure b is versioned")
133
 
        self.assertInWorkingTree(files)
134
 
        self.failUnlessExists(files)
135
 
        tree.remove(['b'], keep_files=False, force=True)
136
 
        b_c = ['b','b/c']
137
 
        self.assertNotInWorkingTree(b_c)
138
 
        self.failIfExists(b_c)
 
136
        self.assertInWorkingTree(TestRemove.files)
 
137
        self.failUnlessExists(TestRemove.files)
 
138
        tree.remove(TestRemove.b, keep_files=False, force=True)
 
139
        self.assertNotInWorkingTree(TestRemove.b_c)
 
140
        self.failIfExists(TestRemove.b_c)
139
141
 
140
142
    def test_remove_keep(self):
141
143
        """check that files are unversioned but not delete."""
142
144
        tree = self.getTree()
143
 
        tree.add(files)
144
 
        self.assertInWorkingTree(files)
 
145
        tree.add(TestRemove.files)
 
146
        self.assertInWorkingTree(TestRemove.files)
145
147
 
146
 
        tree.remove(files)
147
 
        self.assertNotInWorkingTree(files)
148
 
        self.failUnlessExists(files)
 
148
        tree.remove(TestRemove.files)
 
149
        self.assertNotInWorkingTree(TestRemove.files)
 
150
        self.failUnlessExists(TestRemove.files)
149
151
 
150
152
class TestDefaultFormat(TestCaseWithTransport):
151
153