Questions after testtools merge

Robert Collins robertc at robertcollins.net
Tue Dec 29 06:25:40 GMT 2009


On Mon, 2009-12-28 at 23:24 +0000, Martin (gzlist) wrote:
> 
> >> With testtools it seems that naffy _StringException instances are
> >> given to TestResult methods rather than the actual exception. How
> can
> >> this be avoided? Getting the traceback is a pain, as
> >> testtools.content.TracebackContent is just bogus - it will throw on
> >> non-ascii.
> >
> > More details please, I spent some time testing this and getting it
> > solid. the content objects are MIME objects - they can encode
> arbitrary
> > data; if there is a bug in testtools, please file it!
> 
> It's a pain to track down as there are so many levels of indirection,
> but I'm working on it. The MIME thing is just a bad model, tracebacks
> and logs are bytes which do not conform to the envelope the code is
> trying to squish them into. 

MIME can represent bytes too; I chose text for tracebacks because python
unittest treats backtraces as text: the first thing the stock unittest
does is stringify backtraces: putting them in a mime container is a
natural fit. Any encoding issues there are python 2.x issues, as 3.x
doesn't have the horrible ambiguity that 2.x does.

For logs, I started a thread on this list about what encoding the log
should be in, and took the rough opinions from that thread into account
in what I did. Note that prior to this patch landing we showed the log
regardless, and if the encoding was wrong this could corrupt peoples
terminals - the decode-and-replace approach is much better IMO.

As for the indirection: self.getDetails() returns a dict of Mime
objects, each object has a content_type and iter_bytes() method (which
returns a generator of the bytes of the object). text MIME objects have
an iter_text() method too, which decodes using the appropriate codec.

For the issue with _get_log, you haven't described what problem you're
having, only said 'its worse', so I really can't help you much. Can you
at least describe what you want it to do different, and how what it does
now does not work for you? setKeepLogFile is a bad function: it leads to
leaked log files, and I really encourage you to stop using it. Perhaps
you can explain why you want to use it? (Or just try the new code as-is
- it may fix things for you).

-Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20091229/e0ff9746/attachment.pgp 


More information about the bazaar mailing list