2121import os
2222import unittest
2323import email
24+
25+ _TESTDIR = os .path .dirname (os .path .abspath (__file__ ))
2426try :
2527 from Mailman import __init__
2628except ImportError :
@@ -192,9 +194,9 @@ def test_bounce(self):
192194 for modname , file , addrs in self .DATA :
193195 module = 'Mailman.Bouncers.' + modname
194196 __import__ (module )
195- fp = open (os .path .join ('tests' , 'bounces' , file ))
197+ fp = open (os .path .join (_TESTDIR , 'bounces' , file ), 'rb' )
196198 try :
197- msg = email .message_from_file (fp )
199+ msg = email .message_from_binary_file (fp )
198200 finally :
199201 fp .close ()
200202 foundaddrs = sys .modules [module ].process (msg )
@@ -212,9 +214,9 @@ def test_bounce(self):
212214 def test_SMTP32_failure (self ):
213215 from Mailman .Bouncers import SMTP32
214216 # This file has no X-Mailer: header
215- fp = open (os .path .join ('tests' , 'bounces' , 'postfix_01.txt' ))
217+ fp = open (os .path .join (_TESTDIR , 'bounces' , 'postfix_01.txt' ), 'rb' )
216218 try :
217- msg = email .message_from_file (fp )
219+ msg = email .message_from_binary_file (fp )
218220 finally :
219221 fp .close ()
220222 self .failIf (msg ['x-mailer' ] is not None )
0 commit comments