comparison test/test_mailgw.py @ 1330:d008233b22aa

fixes to mailgw tests
author Richard Jones <richard@users.sourceforge.net>
date Wed, 11 Dec 2002 03:17:50 +0000
parents c0546b95aad1
children 58d129ad1050
comparison
equal deleted inserted replaced
1329:b1f86cc82d33 1330:d008233b22aa
6 # 6 #
7 # This module is distributed in the hope that it will be useful, 7 # This module is distributed in the hope that it will be useful,
8 # but WITHOUT ANY WARRANTY; without even the implied warranty of 8 # but WITHOUT ANY WARRANTY; without even the implied warranty of
9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 # 10 #
11 # $Id: test_mailgw.py,v 1.35 2002-12-10 00:46:55 richard Exp $ 11 # $Id: test_mailgw.py,v 1.36 2002-12-11 03:17:50 richard Exp $
12 12
13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib 13 import unittest, cStringIO, tempfile, os, shutil, errno, imp, sys, difflib
14 14
15 # Note: Should parse emails according to RFC2822 instead of performing a 15 # Note: Should parse emails according to RFC2822 instead of performing a
16 # literal string comparision. Parsing the messages allows the tests to work for 16 # literal string comparision. Parsing the messages allows the tests to work for
29 def compareStrings(self, s2, s1): 29 def compareStrings(self, s2, s1):
30 '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants 30 '''Note the reversal of s2 and s1 - difflib.SequenceMatcher wants
31 the first to be the "original" but in the calls in this file, 31 the first to be the "original" but in the calls in this file,
32 the second arg is the original. Ho hum. 32 the second arg is the original. Ho hum.
33 ''' 33 '''
34 if s1 == s2: 34 # we have to special-case the Date: header here 'cos we can't test
35 # for it properly
36 l1=s1.strip().split('\n')
37 l2=[x for x in s2.strip().split('\n') if not x.startswith('Date: ')]
38 if l1 == l2:
35 return 39 return
36 40
37 # under python2.[12] we allow a difference of one trailing empty line.
38 if sys.version_info[0:2] == (2,1):
39 if s1+'\n' == s2:
40 return
41 if sys.version_info[0:2] == (2,2):
42 if s1 == s2+'\n':
43 return
44
45 l1=s1.split('\n')
46 l2=s2.split('\n')
47 s = difflib.SequenceMatcher(None, l1, l2) 41 s = difflib.SequenceMatcher(None, l1, l2)
48 res = ['Generated message not correct (diff follows):'] 42 res = ['Generated message not correct (diff follows):']
49 for value, s1s, s1e, s2s, s2e in s.get_opcodes(): 43 for value, s1s, s1e, s2s, s2e in s.get_opcodes():
50 if value == 'equal': 44 if value == 'equal':
51 for i in range(s1s, s1e): 45 for i in range(s1s, s1e):

Roundup Issue Tracker: http://roundup-tracker.org/