[MERGE] fixes for TestCase.run_bzr* methods

Martin Pool mbp at canonical.com
Tue Sep 25 03:02:59 BST 2007


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.

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?

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.


For details, see: 
http://bundlebuggy.aaronbentley.com/request/%3C46F3C51E.3040709%40ukr.net%3E



More information about the bazaar mailing list