commit 7696471145c2110b95b1eae5b5b66a3098551ce1 Author: Damian Johnson atagar@torproject.org Date: Sat Jan 18 16:21:07 2020 -0800
Fix dkim tests
Oops, unsure how I missed this rfc822 usage when I fixed the other calls. This corrects...
Traceback (most recent call last): File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_email_dkim.py", line 61, in test_checkDKIM_bad message = self._createMessage(self.badMessage) File "/home/atagar/Desktop/tor/bridgedb/bridgedb/test/test_email_dkim.py", line 50, in _createMessage messageIO = io.StringIO(unicode(messageString)) builtins.NameError: name 'unicode' is not defined
Test results changed as follows...
before: FAILED (skips=114, failures=16, errors=82, successes=772) after: FAILED (skips=114, failures=16, errors=76, successes=778) --- bridgedb/distributors/email/dkim.py | 2 +- bridgedb/test/test_email_dkim.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/bridgedb/distributors/email/dkim.py b/bridgedb/distributors/email/dkim.py index be33d59..48118c8 100644 --- a/bridgedb/distributors/email/dkim.py +++ b/bridgedb/distributors/email/dkim.py @@ -63,7 +63,7 @@ def checkDKIM(message, rules): if 'dkim' in rules: # getheader() returns the last of a given kind of header; we want # to get the first, so we use getheaders() instead. - dkimHeaders = message.getheaders("X-DKIM-Authentication-Results") + dkimHeaders = message.get("X-DKIM-Authentication-Results") dkimHeader = "<no header>" if dkimHeaders: dkimHeader = dkimHeaders[0] diff --git a/bridgedb/test/test_email_dkim.py b/bridgedb/test/test_email_dkim.py index 2330a71..679575f 100644 --- a/bridgedb/test/test_email_dkim.py +++ b/bridgedb/test/test_email_dkim.py @@ -11,6 +11,7 @@
"""Unittests for the :mod:`bridgedb.distributors.email.dkim` module."""
+import email import email.message import io
@@ -47,8 +48,7 @@ get bridges
def _createMessage(self, messageString): """Create an ``email.message.Message`` from a string.""" - messageIO = io.StringIO(unicode(messageString)) - return rfc822.Message(messageIO) + return email.message_from_string(messageString)
def test_checkDKIM_good(self): message = self._createMessage(self.goodMessage)
tor-commits@lists.torproject.org