error in the tests

John Arbash Meinel john at arbash-meinel.com
Fri Jan 6 03:32:07 GMT 2006


Martin Pool wrote:
> On Thu, 2006-01-05 at 12:21 -0600, John Arbash Meinel wrote:
> 
> 
>>I was able to reproduce the problem just by adding the line:
>>os.environ['BZREMAIL'] = u'Erik Bågfors <joe at foo.com>'.encode('utf-8')
>>
>>Before the rest of the test. The specific traceback is because when we
>>capture the output of bzr, we basically are just setting sys.stdout to a
>>StringIO object, which has an encoding of 'ascii'. This means that there
>>is no valid encoding.
>>
>>For something like 'missing' or 'log', it is probably okay if the output
>>gets slightly corrupted when characters are not representable in the
>>current character set.
> 
> 
> There was some discussion of this previously - for those "display"
> commands we probably want to write to stdout in errors=replace mode, so
> that you can still get "Erik B?gfors" on an ascii terminal.  For other
> cases, such as writing a diff, replacement is probably not acceptable.
> 
> 
>>I'm thinking to change the run_bzr() code, so that it defaults to
>>creating a 'utf-8' encoded file for sys.stdout. But that we can pass a
>>command such as self.run_bzr(encoding='ascii', retcode=1) to change what
>>the default encoding of sys.stdout is.
>>That should mean generic tests don't fail for Eric, while still letting
>>us write tests that make sure bzr doesn't fail under those conditions.
> 
> 
> I take it you mean the run_bzr used in tests, not the overall entry
> point for bzr?  I think being able to set the overall encoding for bzr
> would be good, but I don't know if it'd be good to default to utf8.
> 
> There was some discussion of adding global options to control it; did
> anything come of that?
> 

Well, I'm doing 2 things in my encodings branch.

First, I'm adding an encoding= parameter to TestCase.run_bzr_captured
Second, I'm modifying Command() so that it has an 'outf' attribute.
Which is set for the correct encoding failure based on
Command.encoding_type()

So for commands like 'cmd_log' which don't care if they get a few
details wrong you use:

class cmd_log(...)

  encoding_type = 'replace'

  def run(...):
    self.outf.write('this will be encoded appropriately.')

I also provide a type 'exact', which doesn't create an encoding. Because
something like 'diff' needs to be more creative with how it writes out
text. It would probably want to encode any filenames, but *doesn't* want
to encode the raw text of files.

I'm pretty happy with it so far. If you feel I'm taking a bad path, let
me know.

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 256 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060105/b456a310/attachment.pgp 


More information about the bazaar mailing list