summaryrefslogtreecommitdiff
path: root/Mailman/testing/emailbase.py
diff options
context:
space:
mode:
authorbwarsaw2006-07-08 17:37:55 +0000
committerbwarsaw2006-07-08 17:37:55 +0000
commitcbef3114de3e80b9436d909b11568858e3a1cf42 (patch)
treef567fe3fbc331fe399b92e93f80068e8995a7821 /Mailman/testing/emailbase.py
parent60b723291e592ff7925e1b15b79161d1cdac5938 (diff)
downloadmailman-cbef3114de3e80b9436d909b11568858e3a1cf42.tar.gz
mailman-cbef3114de3e80b9436d909b11568858e3a1cf42.tar.zst
mailman-cbef3114de3e80b9436d909b11568858e3a1cf42.zip
Massive conversion process so that Mailman can be run from a user specified
configuration file. While the full conversion is not yet complete, everything that seems to be required to run mailmanctl, qrunner, rmlist, and newlist have been updated. Basically, modules should no longer import mm_cfg, but instead they should import Mailman.configuration.config. The latter is an object that's guaranteed to exist, but not guaranteed to be initialized until some top-level script calls config.load(). The latter should be called with the argument to -C/--config which is a new convention the above scripts have been given. In most cases, where mm_cfg.<variable> is used config.<variable> can be used, but the exceptions are where the default value must be available before config.load() is called. Sometimes you can import Mailman.Default and get the variable from there, but other times the code has to be changed to work around this limitation. Take each on a case-by-case basis. Note that the various directories calculated from VAR_PREFIX, EXEC_PREFIX, and PREFIX are now calculated in config.py, not in Defaults.py. This way a configuration file can override the base directories and everything should work correctly. Other changes here include: - mailmanctl, qrunner, and update are switched to optparse and $-strings, and changed to the mmshell architecture - An etc directory has been added to /usr/local/mailman and a mailman.cfg.sample file is installed there. Sites should now edit an etc/mailman.cfg file to do their configurations, although the mm_cfg file is still honored. The formats of the two files are identical. - list_lists is given the -C/--config option - Some coding style fixes in bin/update, but not extensive - Get rid of nested scope hacks in qrunner.py - A start on getting EmailBase tests working (specifically test_message), although not yet complete.
Diffstat (limited to 'Mailman/testing/emailbase.py')
-rw-r--r--Mailman/testing/emailbase.py20
1 files changed, 16 insertions, 4 deletions
diff --git a/Mailman/testing/emailbase.py b/Mailman/testing/emailbase.py
index 115ea6839..6c290c8e5 100644
--- a/Mailman/testing/emailbase.py
+++ b/Mailman/testing/emailbase.py
@@ -17,14 +17,18 @@
"""Base class for tests that email things."""
+import os
import smtpd
import socket
import asyncore
+import tempfile
import subprocess
from Mailman import mm_cfg
from Mailman.testing.base import TestBase
+TESTPORT = 10825
+
MSGTEXT = None
@@ -49,15 +53,23 @@ class SinkServer(smtpd.SMTPServer):
class EmailBase(TestBase):
def setUp(self):
TestBase.setUp(self)
- # Find an unused non-root requiring port to listen on
- oldport = mm_cfg.SMTPPORT
- mm_cfg.SMTPPORT = port = 10825
+ # Find an unused non-root requiring port to listen on. Set up a
+ # configuration file that causes the underlying outgoing runner to use
+ # the same port, then start Mailman.
+ fd, self._configfile = tempfile.mkstemp(suffix='.cfg')
+ print 'config file:', self._configfile
+ fp = os.fdopen(fd, 'w')
+ print >> fp, 'SMTPPORT =', TESTPORT
+ fp.close()
# Second argument is ignored.
- self._server = SinkServer(('localhost', port), None)
+ self._server = SinkServer(('localhost', TESTPORT), None)
+ os.system('bin/mailmanctl start')
def tearDown(self):
+ os.system('bin/mailmanctl stop')
self._server.close()
TestBase.tearDown(self)
+ os.remove(self._configfile)
def _readmsg(self):
global MSGTEXT