[MERGE] [bug #111664] bzr rm refuses to delete renamed files

Robert Collins robertc at robertcollins.net
Mon Jun 25 21:29:19 BST 2007


On Mon, 2007-06-25 at 19:40 +0200, Marius Kruger wrote:
> hopefully this bundle address all the comments on the list.
> The changes I made since the last patch are:

+1 Conditional on one further change:

> === modified file
> 'bzrlib/tests/workingtree_implementations/test_remove.py' 
> --- bzrlib/tests/workingtree_implementations/test_remove.py
> 2007-06-23 17:59:22 +0000
> +++ bzrlib/tests/workingtree_implementations/test_remove.py
> 2007-06-23 19:45:17 +0000
> @@ -34,11 +34,9 @@ class TestRemove(TestCaseWithWorkingTree 
>          self.build_tree(TestRemove.files)
>          return tree
> 
> -    def _assertRemoveErrorContainsRe(self, e, file_detail_re):
> -        # since assertContainsRe can't take a DOTALL parameter like
> -        # normal re.match, use the following to disregard newlines
> -        err = ' '.join(str(e).split())
> -        self.assertContainsRe(err, 'Can\'t remove changed or unknown'
> +    def _assertRemoveErrorContainsRe(self, exception,
> file_detail_re): 
> +        self.assertContainsRe(str(exception),
> +            '(?s)Can\'t remove changed or unknown'
>              ' files:.*' + file_detail_re)

assertRemoveErrorContainsRe can now away completely I think. I propose
the following -
delete the asertRemoveErrorContainsRe method
change 
+        e = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove,
+            TestRemove.files, keep_files=False)
+        self._assertRemoveErrorContainsRe(e, 'unknown:.*b/c.*b.*a.*d')

into

+        err = self.assertRaises(errors.BzrRemoveChangedFilesError, tree.remove,
+            TestRemove.files, keep_files=False)
+        self._assertContainsRe(err.changes_as_text, 'unknown:.*b/c.*b.*a.*d')

The reason for this is:
The exception *formatting* should be tested in bzrlib/tests/test_errors.py
The exception *throwing* should be testing what is supplied to the
BzrRemoveChangedFilesError constructor, not the current formatting which
could change, get internationalised etc.

This reduces the number of layers involved in your tests, and thus the
number of noise changes you may encounter. 

-Rob

-- 


GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20070626/4b37b301/attachment.pgp 


More information about the bazaar mailing list