aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorSimon Glass2019-05-14 15:53:53 -0600
committerSimon Glass2019-07-10 16:52:58 -0600
commite6dca5e8f8d4160a6efed05f5275426e2d274542 (patch)
tree5555060fd0cf542f381345aa2e8bbd34ca8ffe4d /tools
parent7ebb45c7e2e1b8355ec4802e0802ae7b383a6ea5 (diff)
patman: Adjust functional tests for Python 3
Change the code so that it works on both Python 2 and Python 3. This works by using unicode instead of latin1 for the test input, and ensuring that the output is converted to a string rather than a unicode object on Python 2. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/patman/func_test.py25
1 files changed, 14 insertions, 11 deletions
diff --git a/tools/patman/func_test.py b/tools/patman/func_test.py
index f7d5ad68f61..50a2741439e 100644
--- a/tools/patman/func_test.py
+++ b/tools/patman/func_test.py
@@ -129,10 +129,10 @@ class TestFunctional(unittest.TestCase):
"""
process_tags = True
ignore_bad_tags = True
- stefan = u'Stefan Brüns <stefan.bruens@rwth-aachen.de>'
+ stefan = b'Stefan Br\xc3\xbcns <stefan.bruens@rwth-aachen.de>'.decode('utf-8')
rick = 'Richard III <richard@palace.gov>'
- mel = u'Lord Mëlchett <clergy@palace.gov>'
- ed = u'Lond Edmund Blackaddër <weasel@blackadder.org'
+ mel = b'Lord M\xc3\xablchett <clergy@palace.gov>'.decode('utf-8')
+ ed = b'Lond Edmund Blackadd\xc3\xabr <weasel@blackadder.org'.decode('utf-8')
fred = 'Fred Bloggs <f.bloggs@napier.net>'
add_maintainers = [stefan, rick]
dry_run = True
@@ -178,27 +178,30 @@ class TestFunctional(unittest.TestCase):
while 'Cc:' in lines[line]:
line += 1
self.assertEqual('To: u-boot@lists.denx.de', lines[line])
- self.assertEqual('Cc: %s' % stefan.encode('utf-8'), lines[line + 1])
+ self.assertEqual('Cc: %s' % tools.FromUnicode(stefan),
+ lines[line + 1])
self.assertEqual('Version: 3', lines[line + 2])
self.assertEqual('Prefix:\t RFC', lines[line + 3])
self.assertEqual('Cover: 4 lines', lines[line + 4])
line += 5
self.assertEqual(' Cc: %s' % fred, lines[line + 0])
- self.assertEqual(' Cc: %s' % ed.encode('utf-8'), lines[line + 1])
- self.assertEqual(' Cc: %s' % mel.encode('utf-8'), lines[line + 2])
+ self.assertEqual(' Cc: %s' % tools.FromUnicode(ed),
+ lines[line + 1])
+ self.assertEqual(' Cc: %s' % tools.FromUnicode(mel),
+ lines[line + 2])
self.assertEqual(' Cc: %s' % rick, lines[line + 3])
expected = ('Git command: git send-email --annotate '
'--in-reply-to="%s" --to "u-boot@lists.denx.de" '
'--cc "%s" --cc-cmd "%s --cc-cmd %s" %s %s'
% (in_reply_to, stefan, sys.argv[0], cc_file, cover_fname,
- ' '.join(args))).encode('utf-8')
+ ' '.join(args)))
line += 4
- self.assertEqual(expected, lines[line])
+ self.assertEqual(expected, tools.ToUnicode(lines[line]))
- self.assertEqual(('%s %s, %s' % (args[0], rick, stefan))
- .encode('utf-8'), cc_lines[0])
+ self.assertEqual(('%s %s, %s' % (args[0], rick, stefan)),
+ tools.ToUnicode(cc_lines[0]))
self.assertEqual(('%s %s, %s, %s, %s' % (args[1], fred, ed, rick,
- stefan)).encode('utf-8'), cc_lines[1])
+ stefan)), tools.ToUnicode(cc_lines[1]))
expected = '''
This is a test of how the cover