git » chasquid » commit 0f487e5

test: Remove dependency on Python 2

author Alberto Bertogli
2019-08-30 08:46:46 UTC
committer Alberto Bertogli
2019-08-30 08:46:46 UTC
parent e98464c424b6355d85728f8579bb11d0fd6b00ef

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 +1 -1
test/t-05-null_address/content +1 -0
test/t-05-null_address/expected_dsr +1 -0
test/util/mail_diff +3 -5

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: <booooo>
 
 Ñ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: <booooo>
 
 
 
+
 --???????????--
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)