[MERGE] bugfix #131100: bzr --version should care about encoding of stdout
Ian Clatworthy
ian.clatworthy at internode.on.net
Tue Sep 4 04:01:18 BST 2007
Alexander Belchenko wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> This patch fixes the bug by passing file-like object to version.show_version().
bb: tweak
> === modified file 'bzrlib/commands.py'
> - self.outf = codecs.getwriter(output_encoding)(sys.stdout, errors=self.encoding_type)
> + self.outf = codecs.getwriter(output_encoding)(sys.stdout,
> + errors=self.encoding_type)
I believe PEP-8 recommends indenting just one extra level here - not
lining up parameters under existing ones.
> === modified file 'bzrlib/tests/blackbox/test_version.py'
> -from bzrlib.tests.blackbox import ExternalBase
> -
> -
> -class TestVersion(ExternalBase):
> +from bzrlib.tests import TestCase
> +from bzrlib import trace
> +
> +
> +class TestVersion(TestCase):
>
> def test_version(self):
> out = self.run_bzr("version")[0]
> @@ -31,3 +32,27 @@
> self.assertContainsRe(out, r"(?m)^ bzrlib:")
> self.assertContainsRe(out, r"(?m)^ Bazaar configuration:")
> self.assertContainsRe(out, r'(?m)^ Bazaar log file:.*bzr\.log')
> +
> +
> +class TestVersionUnicodeOutput(TestCase):
> +
> + def _check(self, args):
> + old_trace_file = trace._bzr_log_filename
> + trace._bzr_log_filename = u'/\u1234/.bzr.log'
> + try:
> + out = self.run_bzr(args)[0]
> + finally:
> + trace._bzr_log_filename = old_trace_file
That absolute path for the log file looks scary. I'm not sure if our
testing infrastructure will handle that correctly or not. The change
from ExternalBase to TestCase looks harmless to me for TestVersion. For
TestVersionUnicodeOutput though, I expected to see TestCaseInTempDir
instead together with a relative path. Apologies if this is a red
herring - HACKING doesn't say enough to clarify this from what I can
find on the topic in that doc.
Ian C.
More information about the bazaar
mailing list