~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_remove.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2010-07-07 04:03:32 UTC
  • mfrom: (5335.2.3 doc)
  • Revision ID: pqm@pqm.ubuntu.com-20100707040332-we60v2hsd39rumlr
(mbp) developer docs about testing (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005, 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
import os
19
19
import sys
20
20
 
21
21
from bzrlib.tests import SymlinkFeature, TestSkipped
22
 
from bzrlib.tests.blackbox import ExternalBase
 
22
from bzrlib.tests import TestCaseWithTransport
23
23
from bzrlib.workingtree import WorkingTree
24
24
from bzrlib import osutils
25
25
 
31
31
files=(a, b, c, d)
32
32
 
33
33
 
34
 
class TestRemove(ExternalBase):
 
34
class TestRemove(TestCaseWithTransport):
35
35
 
36
36
    def _make_tree_and_add(self, paths):
37
37
        tree = self.make_branch_and_tree('.')
61
61
        f.write("\nsome other new content!")
62
62
        f.close()
63
63
 
64
 
    def run_bzr_remove_changed_files(self, error_regexes, files_to_remove):
 
64
    def run_bzr_remove_changed_files(self, error_regexes, files_to_remove,
 
65
                                     working_dir=None):
65
66
        error_regexes.extend(["Can't safely remove modified or unknown files:",
66
67
            'Use --keep to not delete them,'
67
68
            ' or --force to delete them regardless.'
68
69
            ])
69
70
        self.run_bzr_error(error_regexes,
70
 
            ['remove'] + list(files_to_remove))
 
71
                           ['remove'] + list(files_to_remove),
 
72
                           working_dir=working_dir)
71
73
        #see if we can force it now
72
 
        self.run_bzr(['remove', '--force'] + list(files_to_remove))
 
74
        self.run_bzr(['remove', '--force'] + list(files_to_remove),
 
75
                     working_dir=working_dir)
73
76
 
74
77
    def test_remove_new_no_files_specified(self):
75
78
        tree = self.make_branch_and_tree('.')
196
199
        self.run_bzr("commit -m 'added files'")
197
200
        self.changeFile(a)
198
201
        self.changeFile(c)
199
 
        os.chdir('b')
200
 
        self.run_bzr_remove_changed_files(['modified:[.\s]*a[.\s]*b/c'],
201
 
            ['../a', 'c', '.', '../d'])
202
 
        os.chdir('..')
 
202
        self.run_bzr_remove_changed_files(
 
203
            ['modified:[.\s]*a[.\s]*b/c'],
 
204
            ['../a', 'c', '.', '../d'], working_dir='b')
203
205
        self.assertNotInWorkingTree(files)
204
206
        self.failIfExists(files)
205
207