Mercurial > p > roundup > code
comparison test/test_mailgw.py @ 2202:aed7a7c54a50
fix mailgw test harness
| author | Richard Jones <richard@users.sourceforge.net> |
|---|---|
| date | Fri, 09 Apr 2004 01:32:58 +0000 |
| parents | 18addf2a8596 |
| children | 2623b1afc2b6 |
comparison
equal
deleted
inserted
replaced
| 2200:25b95aa44d60 | 2202:aed7a7c54a50 |
|---|---|
| 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.66 2004-03-22 07:45:40 richard Exp $ | 11 # $Id: test_mailgw.py,v 1.67 2004-04-09 01:32:58 richard Exp $ |
| 12 | 12 |
| 13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 | 13 import unittest, tempfile, os, shutil, errno, imp, sys, difflib, rfc822 |
| 14 | 14 |
| 15 from cStringIO import StringIO | 15 from cStringIO import StringIO |
| 16 | 16 |
| 97 shutil.rmtree(self.dirname) | 97 shutil.rmtree(self.dirname) |
| 98 except OSError, error: | 98 except OSError, error: |
| 99 if error.errno not in (errno.ENOENT, errno.ESRCH): raise | 99 if error.errno not in (errno.ENOENT, errno.ESRCH): raise |
| 100 # create the instance | 100 # create the instance |
| 101 init.install(self.dirname, 'templates/classic') | 101 init.install(self.dirname, 'templates/classic') |
| 102 init.write_select_db(self.dirname, 'anydbm') | 102 init.write_select_db(self.dirname, 'sqlite') |
| 103 init.initialise(self.dirname, 'sekrit') | 103 init.initialise(self.dirname, 'sekrit') |
| 104 | 104 |
| 105 # check we can load the package | 105 # check we can load the package |
| 106 self.instance = instance.open(self.dirname) | 106 self.instance = instance.open(self.dirname) |
| 107 | 107 |
| 127 if error.errno not in (errno.ENOENT, errno.ESRCH): raise | 127 if error.errno not in (errno.ENOENT, errno.ESRCH): raise |
| 128 | 128 |
| 129 def _handle_mail(self, message): | 129 def _handle_mail(self, message): |
| 130 handler = self.instance.MailGW(self.instance, self.db) | 130 handler = self.instance.MailGW(self.instance, self.db) |
| 131 handler.trapExceptions = 0 | 131 handler.trapExceptions = 0 |
| 132 return handler.main(StringIO(message)) | 132 ret = handler.main(StringIO(message)) |
| 133 # handler can close the db on us and open a new one | |
| 134 self.db = handler.db | |
| 135 return ret | |
| 133 | 136 |
| 134 def _get_mail(self): | 137 def _get_mail(self): |
| 135 f = open(SENDMAILDEBUG) | 138 f = open(SENDMAILDEBUG) |
| 136 try: | 139 try: |
| 137 return f.read() | 140 return f.read() |
