[MERGE] fixes for TestCase.run_bzr* methods
Alexander Belchenko
bialix at ukr.net
Tue Sep 25 06:13:39 BST 2007
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Martin Pool пишет:
> Martin Pool has voted tweak.
> Status is now: Conditionally approved
> Comment:
>
>
> === modified file 'bzrlib/tests/__init__.py'
> --- bzrlib/tests/__init__.py 2007-09-13 01:54:49 +0000
> +++ bzrlib/tests/__init__.py 2007-09-21 13:07:41 +0000
> @@ -1320,7 +1320,9 @@
> working_dir):
> """Run bazaar command line, splitting up a string command line."""
> if isinstance(args, basestring):
> - args = list(shlex.split(args))
> + # shlex don't understand unicode strings,
> + # so args should be plain string (bialix 20070906)
> + args = list(shlex.split(str(args)))
> return self._run_bzr_core(args, retcode=retcode,
> encoding=encoding, stdin=stdin, working_dir=working_dir,
> )
>
> The vast majority of tests pass plain byte strings to run_bzr, so will
> be unaffected by this change.
>
> I guess there must be some that do pass unicode otherwise you wouldn't
> need to test this. :-) At the moment they end up with an array of
> unicode characters passed through to the cmd object; with this change
> the cmd object will get an array of default-encoded byte strings. That
> may be fine, but I'm not totally sure that those tests will still be
> fully effective with that change, because I don't know what they're
> trying to test.
I don't remember exactly the name of failing test, something about push.
I can dig into old testing log, when I wrote that fix. If this important,
I'll try to find it.
With this change unicode string args will be encoded as ascii, so it
triggers UnicodeEncodeError, if there is "real" unicode.
> So maybe it would be better for this method to insist that if there is
> autosplitting, the string must be just a byte string? If you want to
> pass unicode, the caller should split it?
This fix try to resolve problem that does not exists on Linux.
I suppose that command line for some test auto-constructed based on
output of some osutils or winutils functions. Almost all of them return
unicode objects for paths or filenames (if sys.platform == 'win32').
IMO it's the case.
> Or if you're satisfied that the tests changed by this are not ones that
> care about how the cmd object is called, then this is probably ok.
The tests actually invoke run_bzr with unicode string that contains ascii-only
characters. But shlex is not used when real bzr script invoked in real
shell: sys.argv is already list of arguments. It's a main difference
between blackbox tests and real life.
- --
[µ]
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFG+JkDzYr338mxwCURAinrAJ4q/7n/R66FcuMdyY9G+DJzMKyajQCfX7ME
Y9FnM96yUy4YdRCfKeoc1ow=
=bFDE
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list