[PATCH 2 of 4 py3] tests: try and fail more gracefully with broken unicode escapes

Augie Fackler raf at durin42.com
Thu Jun 15 15:32:31 EDT 2017


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1497546816 14400
#      Thu Jun 15 13:13:36 2017 -0400
# Node ID 389d9fd524f9355578b46cfffd732429fb813b99
# Parent  9ae07d7aff47d4067215216a02e5744c8c974a9c
tests: try and fail more gracefully with broken unicode escapes

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -2093,13 +2093,17 @@ class TextTestRunner(unittest.TextTestRu
             for tc, __ in testcases:
                 if tc.name in timesd:
                     diff = result.faildata.get(tc.name, b'')
+                    try:
+                        diff = diff.decode('unicode_escape')
+                    except UnicodeDecodeError as e:
+                        diff = '%r decoding diff, sorry' % e
                     tres = {'result': res,
                             'time': ('%0.3f' % timesd[tc.name][2]),
                             'cuser': ('%0.3f' % timesd[tc.name][0]),
                             'csys': ('%0.3f' % timesd[tc.name][1]),
                             'start': ('%0.3f' % timesd[tc.name][3]),
                             'end': ('%0.3f' % timesd[tc.name][4]),
-                            'diff': diff.decode('unicode_escape'),
+                            'diff': diff,
                             }
                 else:
                     # blacklisted test


More information about the Mercurial-devel mailing list