~launchpad-results/launchpad-results/trunk

« back to all changes in this revision

Viewing changes to lib/lpresults/xunit/protocols/checkbox.py

  • Committer: Marc Tardif
  • Date: 2012-01-10 17:25:04 UTC
  • Revision ID: marc.tardif@canonical.com-20120110172504-w6ebyjdx279mqv3w
Fixed decoding of submissions with utf-8 strings.

Show diffs side-by-side

added added

removed removed

Lines of Context:
284
284
 
285
285
    def _getValueAsString(self, node):
286
286
        """Return the value of the attribute "value"."""
287
 
        return unicode(node.attrib["value"])
 
287
        return node.attrib["value"].decode("utf-8")
288
288
 
289
289
    def parseContext(self, result, node):
290
290
        """Parse the <context> part of a submission."""
295
295
            command = child.get("command")
296
296
            if command not in duplicates:
297
297
                duplicates.add(command)
298
 
                result.addContext(child.text, command)
 
298
                text = child.text
 
299
                if text is None:
 
300
                    text = ""
 
301
                result.addContext(text, command)
299
302
            else:
300
303
                self.logger.debug(
301
304
                    "Duplicate command found in tag <info>: %s" % command)
375
378
            assert child.tag == "question", \
376
379
                "Unexpected tag <%s>, expected <question>" % child.tag
377
380
            question = {
378
 
                "name": child.get("name"),
 
381
                "name": child.get("name").decode("utf-8"),
379
382
                "targets": [],
380
383
                }
381
384
            plugin = child.get("plugin", None)
410
413
                    question["targets"].append(target)
411
414
 
412
415
                elif sub_tag in ("comment", "command",):
413
 
                    data = sub_node.text
414
 
                    if data is not None:
415
 
                        question[sub_tag] = data.strip()
 
416
                    text = sub_node.text
 
417
                    if text is None:
 
418
                        text = u""
 
419
                    elif not isinstance(text, unicode):
 
420
                        text = text.decode("utf-8")
 
421
                    question[sub_tag] = text.strip()
416
422
 
417
423
                else:
418
424
                    raise AssertionError(