[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

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



commit 7d7606a94cfc9a6c069aacf237d6fe28ad708b98
Author: Isis Lovecruft <isis@xxxxxxxxxxxxxx>
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@xxxxxxxxx
 To: bridges@localhost
 X-DKIM-Authentication-Results: pass
 Subject: testing
 
 get bridges
-"""))
-        self.badMessage = io.StringIO(unicode("""\
+"""
+        self.badMessage = """\
 From: user@xxxxxxxxx
 To: bridges@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)



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits