From 0f487e5fb5d03c46cf0526947eb7163d1975fbbc Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Fri, 30 Aug 2019 09:46:46 +0100 Subject: [PATCH] test: Remove dependency on Python 2 Python 2 is approaching end of life, and we only need it to run the mail_diff test utility. This patch updates mail_diff to run on Python 3, which only needed minor changes. --- test/README | 2 +- test/t-05-null_address/content | 1 + test/t-05-null_address/expected_dsr | 1 + test/util/mail_diff | 8 +++----- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/test/README b/test/README index b66c76d..7d135fa 100644 --- a/test/README +++ b/test/README @@ -1,6 +1,6 @@ This directory holds end to end tests, written usually in a combination of -shell and some Python. +shell and some Python 3. They're not expected to be portable, as that gets impractical very quickly. They also have some dependencies, listed below. diff --git a/test/t-05-null_address/content b/test/t-05-null_address/content index d4e37cc..daa187f 100644 --- a/test/t-05-null_address/content +++ b/test/t-05-null_address/content @@ -4,3 +4,4 @@ Message-ID: Ñañañañaña! + diff --git a/test/t-05-null_address/expected_dsr b/test/t-05-null_address/expected_dsr index 9639134..05958b3 100644 --- a/test/t-05-null_address/expected_dsr +++ b/test/t-05-null_address/expected_dsr @@ -63,4 +63,5 @@ Message-Id: + --???????????-- diff --git a/test/util/mail_diff b/test/util/mail_diff index 26750e5..2523023 100755 --- a/test/util/mail_diff +++ b/test/util/mail_diff @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import difflib import email.parser @@ -71,7 +71,7 @@ def msg_equals(expected, msg): return False if expected.is_multipart(): - for exp, got in itertools.izip_longest(expected.get_payload(), msg.get_payload()): + for exp, got in itertools.zip_longest(expected.get_payload(), msg.get_payload()): if not msg_equals(exp, got): return False else: @@ -90,8 +90,6 @@ if __name__ == "__main__": f1, f2 = sys.argv[1:3] expected = email.parser.Parser().parse(open(f1)) - - mbox = mailbox.mbox(f2, create=False) - msg = mbox[0] + msg = email.parser.Parser().parse(open(f2)) sys.exit(0 if msg_equals(expected, msg) else 1)