# HG changeset patch # User Oliver Cope # Date 1570785609 -7200 # Fri Oct 11 11:20:09 2019 +0200 # Node ID d957442de7fbcadadb4c880f4cab08a6aa8cbd54 # Parent 7689ea096f336cf6dd4d3b6e8741f630cf6418d3 Fix string encoding issues in test suite diff --git a/mailtools/tests/test_mailer.py b/mailtools/tests/test_mailer.py --- a/mailtools/tests/test_mailer.py +++ b/mailtools/tests/test_mailer.py @@ -347,7 +347,7 @@ from tempfile import NamedTemporaryFile from subprocess import check_output - with NamedTemporaryFile() as tmp: + with NamedTemporaryFile(mode="w", encoding="UTF-8") as tmp: tmp.write( """ import atexit @@ -380,5 +380,5 @@ tmp.flush() output = check_output([sys.executable, tmp.name]).strip() assert ( - output == "message sent: ('fromaddr', ['toaddr'], 'message')" + output == b"message sent: ('fromaddr', ['toaddr'], 'message')" ), repr(output) diff --git a/mailtools/tests/test_utils.py b/mailtools/tests/test_utils.py --- a/mailtools/tests/test_utils.py +++ b/mailtools/tests/test_utils.py @@ -33,7 +33,7 @@ with NamedTemporaryFile(suffix=".txt") as tmp: - tmp.write("hello world") + tmp.write(b"hello world") tmp.flush() result = attachment_from_file(tmp.name) @@ -72,7 +72,7 @@ with NamedTemporaryFile(suffix=".txt") as tmp: - tmp.write("hello world") + tmp.write(b"hello world") tmp.flush() result = attachment_from_file(tmp) @@ -90,7 +90,7 @@ with NamedTemporaryFile(suffix=".txt") as tmp: - tmp.write("hello world") + tmp.write(b"hello world") tmp.flush() result = attachment_from_file(tmp, "foo.png")