[MERGE][Bug #116143] commit raises UnicodeError (traceback) if LANG is incorrect (attempt #2)

Aaron Bentley aaron.bentley at utoronto.ca
Sun Jul 29 15:30:03 BST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi Daniel,

!resubmit please.

It looks like you're testing the right thing, but the test is in the
wrong way.

> +    def test_unsupported_encoding_commit_message(self):
> +        self.run_bzr("init")

We only use run_bzr for the thing we're actually testing.  For setting
up the test conditions, we use internal functions.  This would be:

tree = self.make_branch_and_tree('.')

> +        file('foo.c', 'wt').write('int main() {}')

We try to always invoke file.close, because Windows behaves badly if it
is missing.  But we have helpers that do this for us:

self.build_tree_contents([('foo.c', 'int main() {}')])

> +        self.run_bzr('add foo.c')

tree.add('foo.c')

> +        old_enc = osutils.set_or_unset_env('LANG', 'C')
> +        out,err = self.run_bzr_subprocess('commit -m "\xff"', retcode=1)
> +        osutils.set_or_unset_env('LANG', old_enc)

run_bzr_subprocess provides a mechanism for setting environment
variables in the subprocess:
out,err = self.run_bzr_subprocess('commit -m "\xff"', retcode=1,
                                  env_changes={'LANG', 'C'})

> @@ -89,6 +94,7 @@
>          f = file('fed.py', 'wb')
>          f.write('#!%s\n' % sys.executable)
>          f.write("""\
> +# coding=utf-8

Please don't introduce commented-out code.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGrKRr0F+nu1YWqI0RApxFAJ9moj+a4UTjjKYHuttwJ3MyuFmxEgCdGKV9
rWfkIvXWgr4ZAeYCghALQO4=
=Bkb1
-----END PGP SIGNATURE-----



More information about the bazaar mailing list