TestProtocolClient does not UTF-8 encode test ids

Reported by Jonathan Lange on 2012-07-27
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
subunit
High
Robert Collins

Bug Description

From the README:
  test|testing|test:|testing: test LABEL
  ...
  LABEL: UTF8*

$ python2
Python 2.7.3 (default, Apr 20 2012, 22:39:59)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from testtools import PlaceHolder
>>> test = PlaceHolder(u'☃')
>>> test.id()
u'\u2603'
>>> from subunit import TestProtocolClient
>>> import sys
>>> client = TestProtocolClient(sys.stdout)
>>> client.startTest(test)
test: ☃
>>> client.addSuccess(test)
successful: ☃
>>> client.stopTest(test)
>>>

Related branches

Jonathan Lange (jml) wrote :

On 27 July 2012 11:46, Robert Collins <email address hidden> wrote:
> Evil man.

FWIW, this came up using subunit as a streaming format for collecting
results of doing an en masse auto-packaging. It seemed like (and
mostly is) an effective format for pulling everything together and
analyzing the results.

It's just that some people have the temerity to name their
applications in their own, non-English languages!

jml

Robert Collins (lifeless) wrote :

So I realise looking at this trace, that it doesn't tell me if its utf8 encoded or not, because if your terminal is unicode, that will get interpreted. What we need is a repr of the bytes output.

Robert Collins (lifeless) wrote :

This is the code;
        self._stream.write(_b("test: %s\n" % test.id()))

which on 2.x will write unicode and thus do a default conversion. On 3.x it will do a latin-1 conversion. So, buggy.

Changed in subunit:
status: New → Fix Committed
importance: Undecided → High
assignee: nobody → Robert Collins (lifeless)
milestone: none → next
Changed in subunit:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers