From a86be44b08fe0935fe77d90948b9baad85af3624 Mon Sep 17 00:00:00 2001 From: Barry Warsaw Date: Wed, 12 Nov 2008 23:02:29 -0500 Subject: Apply Heiko Rommel's patch for hashlib deprecation warnings for bug 293178. I've modified the patch to improve some of the stylistic issues. --- tests/test_handlers.py | 9 +++++---- tests/test_security_mgr.py | 16 ++++++++-------- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'tests') diff --git a/tests/test_handlers.py b/tests/test_handlers.py index 66c583f7..17e5ec96 100644 --- a/tests/test_handlers.py +++ b/tests/test_handlers.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2003 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -12,13 +12,13 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Unit tests for the various Mailman/Handlers/*.py modules. """ import os -import sha import time import email import errno @@ -53,13 +53,14 @@ from Mailman.Handlers import ToArchive from Mailman.Handlers import ToDigest from Mailman.Handlers import ToOutgoing from Mailman.Handlers import ToUsenet +from Mailman.Utils import sha_new from TestBase import TestBase def password(plaintext): - return sha.new(plaintext).hexdigest() + return sha_new(plaintext).hexdigest() diff --git a/tests/test_security_mgr.py b/tests/test_security_mgr.py index c63f0876..e829d0c9 100644 --- a/tests/test_security_mgr.py +++ b/tests/test_security_mgr.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001-2003 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -12,7 +12,8 @@ # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +# USA. """Unit tests for Mailman/SecurityManager.py """ @@ -20,8 +21,6 @@ import os import unittest import errno -import md5 -import sha import Cookie try: import crypt @@ -33,13 +32,14 @@ from StringIO import StringIO from Mailman import mm_cfg from Mailman import Utils from Mailman import Errors +from Mailman.Utils import md5_new, sha_new from TestBase import TestBase def password(plaintext): - return sha.new(plaintext).hexdigest() + return sha_new(plaintext).hexdigest() @@ -132,7 +132,7 @@ class TestAuthenticate(TestBase): def test_list_admin_upgrade(self): eq = self.assertEqual mlist = self._mlist - mlist.password = md5.new('ssSSss').digest() + mlist.password = md5_new('ssSSss').digest() eq(mlist.Authenticate( [mm_cfg.AuthListAdmin], 'ssSSss'), mm_cfg.AuthListAdmin) eq(mlist.password, password('ssSSss')) @@ -146,10 +146,10 @@ class TestAuthenticate(TestBase): def test_list_admin_oldstyle_unauth(self): eq = self.assertEqual mlist = self._mlist - mlist.password = md5.new('ssSSss').digest() + mlist.password = md5_new('ssSSss').digest() eq(mlist.Authenticate( [mm_cfg.AuthListAdmin], 'xxxxxx'), mm_cfg.UnAuthorized) - eq(mlist.password, md5.new('ssSSss').digest()) + eq(mlist.password, md5_new('ssSSss').digest()) # Test crypt upgrades if crypt is supported if crypt: mlist.password = crypted = crypt.crypt('rrRRrr', 'zc') -- cgit v1.2.3 From f579d5c290b80e00974e8c034f9d6dd697fcdfa6 Mon Sep 17 00:00:00 2001 From: Mark Sapiro Date: Sun, 30 Nov 2008 20:30:43 -0800 Subject: Now that Python 2.4 is the minimum and we will use more recent installed email packages, convert all the email message get_type() calls to get_content_type(). --- tests/test_handlers.py | 20 ++++++++++---------- tests/test_message.py | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'tests') diff --git a/tests/test_handlers.py b/tests/test_handlers.py index 17e5ec96..7b053c65 100644 --- a/tests/test_handlers.py +++ b/tests/test_handlers.py @@ -133,7 +133,7 @@ From: aperson@dom.ain eq(str(str(qmsg['subject'])), '_xtest post acknowledgement') eq(qmsg['to'], 'aperson@dom.ain') eq(qmsg['from'], '_xtest-bounces@dom.ain') - eq(qmsg.get_type(), 'text/plain') + eq(qmsg.get_content_type(), 'text/plain') eq(qmsg.get_param('charset'), 'us-ascii') msgid = qmsg['message-id'] self.failUnless(msgid.startswith(' """) MimeDel.process(self._mlist, msg, {}) - eq(msg.get_type(), 'text/plain') + eq(msg.get_content_type(), 'text/plain') eq(msg.get_payload(), '\n\n\n') def test_deep_structure(self): @@ -1265,13 +1265,13 @@ aaa payload = msg.get_payload() eq(len(payload), 3) part1 = msg.get_payload(0) - eq(part1.get_type(), 'text/plain') + eq(part1.get_content_type(), 'text/plain') eq(part1.get_payload(), 'A different message') part2 = msg.get_payload(1) - eq(part2.get_type(), 'image/gif') + eq(part2.get_content_type(), 'image/gif') eq(part2.get_payload(), 'zzz') part3 = msg.get_payload(2) - eq(part3.get_type(), 'image/gif') + eq(part3.get_content_type(), 'image/gif') eq(part3.get_payload(), 'aaa') def test_top_multipart_alternative(self): @@ -1292,7 +1292,7 @@ This is plain text --AAA-- """) MimeDel.process(self._mlist, msg, {}) - eq(msg.get_type(), 'text/plain') + eq(msg.get_content_type(), 'text/plain') eq(msg.get_payload(), 'This is plain text') diff --git a/tests/test_message.py b/tests/test_message.py index da6f8a08..6a4cc3d2 100644 --- a/tests/test_message.py +++ b/tests/test_message.py @@ -1,4 +1,4 @@ -# Copyright (C) 2001 by the Free Software Foundation, Inc. +# Copyright (C) 2001-2008 by the Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -81,10 +81,10 @@ yadda yadda yadda # second message is the message/rfc822 attachment of the original # message. msg1 = qmsg.get_payload(0) - eq(msg1.get_type(), 'text/plain') + eq(msg1.get_content_type(), 'text/plain') eq(msg1.get_payload(), '[No bounce details are available]\n') msg2 = qmsg.get_payload(1) - eq(msg2.get_type(), 'message/rfc822') + eq(msg2.get_content_type(), 'message/rfc822') unless(not msg2.is_multipart()) msg3 = msg2.get_payload() eq(msg3.get_payload(), 'yadda yadda yadda\n') -- cgit v1.2.3