# HG changeset patch # User Gregory Szorc # Date 1549041219 28800 # Node ID 3028b4073be12902a9015b5f846cbd9583c49918 # Parent e095a9688a31c2985c4133da50692f4f65245678 tests: convert ParseError arguments to str on Python 3 Arguments internally are bytes. Printing the exception on Python 3 will include b'' prefixes. This test file uses a .out file, which doesn't support conditional output. The easiest way to get this to pass on Python 3 is to normalize the exception before printing so there are no b'' prefixes. Differential Revision: https://phab.mercurial-scm.org/D5793 diff -r e095a9688a31 -r 3028b4073be1 tests/test-trusted.py --- a/tests/test-trusted.py Thu Jan 31 22:01:09 2019 -0500 +++ b/tests/test-trusted.py Fri Feb 01 09:13:39 2019 -0800 @@ -222,15 +222,25 @@ f.write(b'foo') f.close() +# This is a hack to remove b'' prefixes from ParseError.__bytes__ on +# Python 3. +def normalizeparseerror(e): + if pycompat.ispy3: + args = [a.decode('utf-8') for a in e.args] + else: + args = e.args + + return error.ParseError(*args) + try: testui(user=b'abc', group=b'def', silent=True) except error.ParseError as inst: - bprint(inst) + bprint(normalizeparseerror(inst)) try: testui(debug=True, silent=True) except error.ParseError as inst: - bprint(inst) + bprint(normalizeparseerror(inst)) print() bprint(b'# access typed information')