[PATCH] tests for all bzrlib.msgeditor functions
Martin Pool
mbp at sourcefrog.net
Fri Jan 6 01:12:01 GMT 2006
On Thu, 2006-01-05 at 21:08 +0200, Alexander Belchenko wrote:
> I'm proud to send the patch that introduce new tests for all msgeditor
> functions (and fix some small win32 issues). I was start to work only on
> test for edit_commit_message, but in process I need to tests all
> functions to found bug in my test :-)
>
> Attached final version tested on win32. This patch also contain fix for
> encoding error in edit_commit_message when infotext is unicode string.
>
> Please review this patch and test this on Linux. I'm very interested in
> results.
>
> --
> Alexander
> plain text document attachment (test_msgeditor.diff)
> === modified file 'bzrlib/msgeditor.py'
> --- bzrlib/msgeditor.py
> +++ bzrlib/msgeditor.py
> @@ -74,6 +74,7 @@
> 'bzr status'.
> """
> import tempfile
> + import bzrlib
>
> if ignoreline is None:
> ignoreline = "-- This line and the following will be ignored --"
> @@ -84,7 +85,8 @@
> if infotext is not None and infotext != "":
> hasinfo = True
> msgfile = file(msgfilename, "w")
> - msgfile.write("\n\n%s\n\n%s" % (ignoreline, infotext))
> + msgfile.write("\n\n%s\n\n%s" % (ignoreline,
> + infotext.encode(bzrlib.user_encoding, "replace")))
> msgfile.close()
> else:
> hasinfo = False
> @@ -126,6 +128,7 @@
> # delete the msg file in any case
> try: os.unlink(msgfilename)
> except IOError: pass
> + except OSError: pass # avoid win32 'Permission denied'
If we only expect to catch "permission denied" then I'd prefer it
specifically checked for that errno, otherwise re-raised. Otherwise
this can hide other unexpected errors that might happen to come up.
Otherwise, +1 from me. Since John has merged it I'll wait to merge from
him.
--
Martin
-------------- 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/20060106/ebe25982/attachment.pgp
More information about the bazaar
mailing list