diff options
| author | Barry Warsaw | 2009-10-15 23:19:53 -0400 |
|---|---|---|
| committer | Barry Warsaw | 2009-10-15 23:19:53 -0400 |
| commit | 27d5a243fdb2bad9e54019c2d6fc08c68bf66fc4 (patch) | |
| tree | 9a0d84faaffcde9e75fe41b633107c98cbee4b49 /src/mailman/testing/helpers.py | |
| parent | d0eff3c214b4940cb30ec1152fcabf0f34f49194 (diff) | |
| download | mailman-27d5a243fdb2bad9e54019c2d6fc08c68bf66fc4.tar.gz mailman-27d5a243fdb2bad9e54019c2d6fc08c68bf66fc4.tar.zst mailman-27d5a243fdb2bad9e54019c2d6fc08c68bf66fc4.zip | |
Diffstat (limited to 'src/mailman/testing/helpers.py')
| -rw-r--r-- | src/mailman/testing/helpers.py | 60 |
1 files changed, 0 insertions, 60 deletions
diff --git a/src/mailman/testing/helpers.py b/src/mailman/testing/helpers.py index a54e26c82..a10898d5d 100644 --- a/src/mailman/testing/helpers.py +++ b/src/mailman/testing/helpers.py @@ -40,11 +40,8 @@ import smtplib import datetime import threading -from Queue import Empty, Queue - from mailman.bin.master import Loop as Master from mailman.config import config -from mailman.testing.smtplistener import Server from mailman.utilities.mailbox import Mailbox @@ -191,63 +188,6 @@ class TestableMaster(Master): -class SMTPServer: - """An smtp server for testing.""" - - def __init__(self): - self._messages = [] - self._queue = Queue() - self.host = config.mta.smtp_host - self.port = int(config.mta.smtp_port) - self._server = Server((self.host, self.port), self._queue) - self._thread = threading.Thread(target=self._server.start) - self._thread.daemon = True - - def start(self): - """Start the smtp server in a thread.""" - log.info('test SMTP server starting') - self._thread.start() - smtpd = smtplib.SMTP() - log.info('connecting to %s:%s', self.host, self.port) - smtpd.connect(self.host, self.port) - response = smtpd.helo('test.localhost') - smtpd.quit() - log.info('SMTP server is running: %s', response) - - def stop(self): - """Stop the smtp server.""" - smtpd = smtplib.SMTP() - smtpd.connect(self.host, self.port) - smtpd.docmd('EXIT') - 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.""" - # 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: - break - else: - self._messages.append(message) - # Now return all the messages we know about. - for message in self._messages: - yield message - - def clear(self): - """Clear all messages from the queue.""" - # Just throw these away. - list(self._messages) - self._messages = [] - - - class LMTP(smtplib.SMTP): """Like a normal SMTP client, but for LMTP.""" def lhlo(self, name=''): |
