[tor-commits] [bridgedb/develop] Add _createMessage() utility to test_email_dkim.py.

isis at torproject.org isis at torproject.org
Fri Jun 6 20:40:38 UTC 2014


commit 7d7606a94cfc9a6c069aacf237d6fe28ad708b98
Author: Isis Lovecruft <isis at torproject.org>
Date:   Thu Jun 5 02:58:40 2014 +0000

    Add _createMessage() utility to test_email_dkim.py.
---
 lib/bridgedb/test/test_email_dkim.py |   17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/lib/bridgedb/test/test_email_dkim.py b/lib/bridgedb/test/test_email_dkim.py
index 3350d19..3407fa5 100644
--- a/lib/bridgedb/test/test_email_dkim.py
+++ b/lib/bridgedb/test/test_email_dkim.py
@@ -24,36 +24,41 @@ class CheckDKIMTests(unittest.TestCase):
 
     def setUp(self):
         """Create fake email, distributor, and associated context data."""
-        self.goodMessage = io.StringIO(unicode("""\
+        self.goodMessage = """\
 From: user at gmail.com
 To: bridges at localhost
 X-DKIM-Authentication-Results: pass
 Subject: testing
 
 get bridges
-"""))
-        self.badMessage = io.StringIO(unicode("""\
+"""
+        self.badMessage = """\
 From: user at gmail.com
 To: bridges at localhost
 Subject: testing
 
 get bridges
-"""))
+"""
         self.domainRules = {
             'gmail.com': ["ignore_dots", "dkim"],
             'example.com': [],
             'localhost': [],
         }
 
+    def _createMessage(self, messageString):
+        """Create an ``rfc822.Message`` from a string."""
+        messageIO = io.StringIO(unicode(messageString))
+        return rfc822.Message(messageIO)
+
     def test_checkDKIM_good(self):
-        message = rfc822.Message(self.goodMessage)
+        message = self._createMessage(self.goodMessage)
         result = dkim.checkDKIM(message,
                                 self.domainRules.get("gmail.com"))
         self.assertTrue(result)
                                          
 
     def test_checkDKIM_bad(self):
-        message = rfc822.Message(self.badMessage)
+        message = self._createMessage(self.badMessage)
         result = dkim.checkDKIM(message,
                                 self.domainRules.get("gmail.com"))
         self.assertIs(result, False)





More information about the tor-commits mailing list