diff options
| author | Barry Warsaw | 2008-03-27 05:14:14 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2008-03-27 05:14:14 -0400 |
| commit | 17f286de64cb3373d68c4fefba6d9369b4e3f960 (patch) | |
| tree | 5078531044f0574dfa340a389bd6d0bb9eea717f /mailman/tests/helpers.py | |
| parent | de9deb660c5d48a083f0c56916cca6aa0cb010b3 (diff) | |
| download | mailman-17f286de64cb3373d68c4fefba6d9369b4e3f960.tar.gz mailman-17f286de64cb3373d68c4fefba6d9369b4e3f960.tar.zst mailman-17f286de64cb3373d68c4fefba6d9369b4e3f960.zip | |
Diffstat (limited to 'mailman/tests/helpers.py')
| -rw-r--r-- | mailman/tests/helpers.py | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/mailman/tests/helpers.py b/mailman/tests/helpers.py index 71b3ff60e..d1eda9e34 100644 --- a/mailman/tests/helpers.py +++ b/mailman/tests/helpers.py @@ -34,6 +34,7 @@ import time import errno import signal import socket +import logging import mailbox import smtplib import tempfile @@ -48,6 +49,9 @@ from mailman.queue import Switchboard from mailman.tests.smtplistener import Server +log = logging.getLogger('mailman.debug') + + def make_testable_runner(runner_class): """Create a queue runner that runs until its queue is empty. @@ -97,7 +101,7 @@ def digest_mbox(mlist): :param mlist: The mailing list. :return: The mailing list's pending digest as a mailbox. """ - path = os.path.join(mlist.full_path, 'digest.mbox') + path = os.path.join(mlist.data_path, 'digest.mbox') return mailbox.mbox(path) @@ -168,6 +172,7 @@ class SMTPServer: def start(self): """Start the smtp server in a thread.""" + log.info('test SMTP server starting') self._thread.start() def stop(self): @@ -178,18 +183,22 @@ class SMTPServer: self.clear() # Wait for the thread to exit. self._thread.join() + log.info('test SMTP server stopped') @property def messages(self): """Return all the messages received by the smtp server.""" - for message in self._messages: - # See if there's anything waiting in the queue. + # Look at the thread queue and append any messages from there to our + # internal list of messages. + while True: try: message = self._queue.get_nowait() except Empty: - pass + break else: self._messages.append(message) + # Now return all the messages we know about. + for message in self._messages: yield message def clear(self): |
