diff options
| author | bwarsaw | 2007-03-21 14:11:53 +0000 |
|---|---|---|
| committer | bwarsaw | 2007-03-21 14:11:53 +0000 |
| commit | fc51f4c9de9751c03fb21394b393253e8c225453 (patch) | |
| tree | a931a2a61e156ca8332a92d6369163741f8e506d /Mailman/testing/base.py | |
| parent | cf950f7430ecabc8d4ff370c4f9e6e01f7b44fd4 (diff) | |
| download | mailman-fc51f4c9de9751c03fb21394b393253e8c225453.tar.gz mailman-fc51f4c9de9751c03fb21394b393253e8c225453.tar.zst mailman-fc51f4c9de9751c03fb21394b393253e8c225453.zip | |
Diffstat (limited to 'Mailman/testing/base.py')
| -rw-r--r-- | Mailman/testing/base.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Mailman/testing/base.py b/Mailman/testing/base.py index a61740956..2979ad18b 100644 --- a/Mailman/testing/base.py +++ b/Mailman/testing/base.py @@ -19,7 +19,9 @@ import os import grp +import new import pwd +import sys import stat import shutil import difflib @@ -39,6 +41,11 @@ NL = '\n' +def dummy_mta_function(*args, **kws): + pass + + + class TestBase(unittest.TestCase): def _configure(self, fp): # Make sure that we don't pollute the real database with our test @@ -46,6 +53,9 @@ class TestBase(unittest.TestCase): test_engine_url = 'sqlite:///' + self._dbfile print >> fp, 'SQLALCHEMY_ENGINE_URL = "%s"' % test_engine_url config.SQLALCHEMY_ENGINE_URL = test_engine_url + # Use the Mailman.MTA.stub module + print >> fp, 'MTA = "stub"' + config.MTA = 'stub' print >> fp, 'add_domain("example.com", "www.example.com")' # Only add this domain once to the current process if 'example.com' not in config.domains: @@ -80,6 +90,12 @@ class TestBase(unittest.TestCase): self._configure(fp) finally: fp.close() + # Create a fake new Mailman.MTA module which stubs out the create() + # and remove() functions. + stubmta_module = new.module('Mailman.MTA.stub') + sys.modules['Mailman.MTA.stub'] = stubmta_module + stubmta_module.create = dummy_mta_function + stubmta_module.remove = dummy_mta_function # Be sure to close the connection to the current database, and then # reconnect to the new temporary SQLite database. Otherwise we end up # with turds in the main database and our qrunner subprocesses won't |
