Patchwork [6,of,8] tests: fix run-tests XML reporting on Python 3

login
register
mail settings
Submitter Augie Fackler
Date Sept. 19, 2017, 4:35 a.m.
Message ID <6ff0c726b7b203911936.1505795723@augie-macbookpro2.roam.corp.google.com>
Download mbox | patch
Permalink /patch/24012/
State Accepted
Headers show

Comments

Augie Fackler - Sept. 19, 2017, 4:35 a.m.
# HG changeset patch
# User Augie Fackler <augie@google.com>
# Date 1505794177 14400
#      Tue Sep 19 00:09:37 2017 -0400
# Node ID 6ff0c726b7b203911936a39ddf85b83c74062ead
# Parent  5cc38d6d9eabd872af4c553ef93eace0b6fc4ab2
tests: fix run-tests XML reporting on Python 3

cdatasafe wants to work in terms of bytes, but of course we have a
unicode. Easy to work around, especially since we know we'll get utf-8
at the end.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2194,7 +2194,8 @@  class TextTestRunner(unittest.TextTestRu
             # the skip message as a text node instead.
             t = doc.createElement('testcase')
             t.setAttribute('name', tc.name)
-            message = cdatasafe(message).decode('utf-8', 'replace')
+            binmessage = message.encode('utf-8')
+            message = cdatasafe(binmessage).decode('utf-8', 'replace')
             cd = doc.createCDATASection(message)
             skipelem = doc.createElement('skipped')
             skipelem.appendChild(cd)