Barry Warsaw has proposed merging lp:~barry/mailman/nose2 into lp:mailman.
Requested reviews:
Mailman Coders (mailman-coders)
For more details, see:
https://code.launchpad.net/~barry/mailman/nose2/+merge/182144
Get rid of zc.buildout and zope.testing. Instead, use virtualenv and nose2.
--
https://code.launchpad.net/~barry/mailman/nose2/+merge/182144
Your team Mailman Coders is requested to review the proposed merge of
lp:~barry/mailman/nose2 into lp:mailman.
=== modified file 'setup.py'
--- setup.py 2013-01-05 23:10:43 +0000
+++ setup.py 2013-08-26 15:55:35 +0000
@@ -101,14 +101,14 @@
'lazr.config',
'lazr.smtptest',
'mock',
+ 'nose2',
'passlib',
'restish',
'storm',
- 'zc.buildout',
'zope.component',
'zope.configuration',
'zope.event',
'zope.interface',
- 'zope.testing<4',
],
+ test_suite = 'nose2.collector.collector',
)
=== modified file 'src/mailman/__init__.py'
--- src/mailman/__init__.py 2013-01-01 14:05:42 +0000
+++ src/mailman/__init__.py 2013-08-26 15:55:35 +0000
@@ -44,7 +44,7 @@
#
# Do *not* do this if we're building the documentation.
if 'build_sphinx' not in sys.argv:
- if sys.argv[0].split(os.sep)[-1] == 'test':
+ if any('nose2' in arg for arg in sys.argv):
from mailman.testing.i18n import initialize
else:
from mailman.core.i18n import initialize
=== modified file 'src/mailman/app/docs/hooks.rst'
--- src/mailman/app/docs/hooks.rst 2011-09-24 01:42:39 +0000
+++ src/mailman/app/docs/hooks.rst 2013-08-26 15:55:35 +0000
@@ -52,8 +52,9 @@
>>> import subprocess
>>> from mailman.testing.layers import ConfigLayer
>>> def call():
+ ... exe = os.path.join(os.path.dirname(sys.executable), 'mailman')
... proc = subprocess.Popen(
- ... 'bin/mailman lists --domain ignore -q'.split(),
+ ... [exe, 'lists', '--domain', 'ignore', '-q'],
... cwd=ConfigLayer.root_directory,
... env=dict(MAILMAN_CONFIG_FILE=config_path,
... PYTHONPATH=config_directory),
=== modified file 'src/mailman/model/docs/autorespond.rst'
--- src/mailman/model/docs/autorespond.rst 2011-09-24 01:42:39 +0000
+++ src/mailman/model/docs/autorespond.rst 2013-08-26 15:55:35 +0000
@@ -90,7 +90,7 @@
>>> response.address
<Address: [email protected] [not verified] at ...>
>>> response.response_type
- <EnumValue: Response.hold [int=1]>
+ <EnumValue: Response.hold [value=1]>
>>> response.date_sent
datetime.date(2005, 8, 1)
=== modified file 'src/mailman/testing/__init__.py'
--- src/mailman/testing/__init__.py 2013-01-01 14:05:42 +0000
+++ src/mailman/testing/__init__.py 2013-08-26 15:55:35 +0000
@@ -1,39 +0,0 @@
-# Copyright (C) 2011-2013 by the Free Software Foundation, Inc.
-#
-# This file is part of GNU Mailman.
-#
-# GNU Mailman is free software: you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free
-# Software Foundation, either version 3 of the License, or (at your option)
-# any later version.
-#
-# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
-# more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
-
-"""Set up testing.
-
-This is used as an interface to buildout.cfg's [test] section.
-zope.testrunner supports an initialization variable. It is set to import and
-run the following test initialization method.
-"""
-
-from __future__ import absolute_import, unicode_literals
-
-__metaclass__ = type
-__all__ = [
- 'initialize',
- ]
-
-
-
-def initialize(root_directory):
- """Initialize the test infrastructure."""
- from mailman.testing import layers
- layers.MockAndMonkeyLayer.testing_mode = True
- layers.ConfigLayer.enable_stderr();
- layers.ConfigLayer.set_root_directory(root_directory)
=== renamed file 'src/mailman/tests/test_documentation.py' => 'src/mailman/testing/documentation.py'
--- src/mailman/tests/test_documentation.py 2013-01-01 14:05:42 +0000
+++ src/mailman/testing/documentation.py 2013-08-26 15:55:35 +0000
@@ -25,23 +25,16 @@
__metaclass__ = type
__all__ = [
- 'test_suite',
+ 'setup',
+ 'teardown'
]
-import os
-import sys
-import doctest
-import unittest
-
from inspect import isfunction, ismethod
-import mailman
-
from mailman.app.lifecycle import create_list
from mailman.config import config
-from mailman.testing.helpers import (
- call_api, chdir, specialized_message_from_string)
+from mailman.testing.helpers import call_api, specialized_message_from_string
from mailman.testing.layers import SMTPLayer
@@ -181,53 +174,3 @@
cleanup()
else:
cleanup[0](*cleanup[1:])
-
-
-
-def test_suite():
- """Create test suites for all .rst documentation tests.
-
- .txt files are also tested, but .rst is highly preferred.
- """
- suite = unittest.TestSuite()
- topdir = os.path.dirname(mailman.__file__)
- packages = []
- for dirpath, dirnames, filenames in os.walk(topdir):
- if 'docs' in dirnames:
- docsdir = os.path.join(dirpath, 'docs')[len(topdir)+1:]
- packages.append(docsdir)
- # Under higher verbosity settings, report all doctest errors, not just the
- # first one.
- flags = (doctest.ELLIPSIS |
- doctest.NORMALIZE_WHITESPACE |
- doctest.REPORT_NDIFF)
- # Add all the doctests in all subpackages.
- doctest_files = {}
- with chdir(topdir):
- for docsdir in packages:
- # Look to see if the package defines a test layer, otherwise use
- # SMTPLayer.
- package_path = 'mailman.' + DOT.join(docsdir.split(os.sep))
- try:
- __import__(package_path)
- except ImportError:
- layer = SMTPLayer
- else:
- layer = getattr(sys.modules[package_path], 'layer', SMTPLayer)
- for filename in os.listdir(docsdir):
- base, extension = os.path.splitext(filename)
- if os.path.splitext(filename)[1] in ('.txt', '.rst'):
- module_path = package_path + '.' + base
- doctest_files[module_path] = (
- os.path.join(docsdir, filename), layer)
- for module_path in sorted(doctest_files):
- path, layer = doctest_files[module_path]
- test = doctest.DocFileSuite(
- path,
- package='mailman',
- optionflags=flags,
- setUp=setup,
- tearDown=teardown)
- test.layer = layer
- suite.addTest(test)
- return suite
=== modified file 'src/mailman/testing/layers.py'
--- src/mailman/testing/layers.py 2013-06-17 13:36:43 +0000
+++ src/mailman/testing/layers.py 2013-08-26 15:55:35 +0000
@@ -154,7 +154,7 @@
continue
logger_name = 'mailman.' + sub_name
log = logging.getLogger(logger_name)
- log.propagate = True
+ #log.propagate = True
# Reopen the file to a new path that tests can get at. Instead of
# using the configuration file path though, use a path that's
# specific to the logger so that tests can find expected output
=== added file 'src/mailman/testing/nose.py'
--- src/mailman/testing/nose.py 1970-01-01 00:00:00 +0000
+++ src/mailman/testing/nose.py 2013-08-26 15:55:35 +0000
@@ -0,0 +1,99 @@
+# Copyright (C) 2013 by the Free Software Foundation, Inc.
+#
+# This file is part of GNU Mailman.
+#
+# GNU Mailman is free software: you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free
+# Software Foundation, either version 3 of the License, or (at your option)
+# any later version.
+#
+# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+# more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
+
+"""nose2 test infrastructure."""
+
+from __future__ import absolute_import, print_function, unicode_literals
+
+__metaclass__ = type
+__all__ = [
+ 'NosePlugin',
+ ]
+
+
+import os
+import re
+import doctest
+import mailman
+import importlib
+
+from mailman.testing.documentation import setup, teardown
+from mailman.testing.layers import ConfigLayer, MockAndMonkeyLayer, SMTPLayer
+from nose2.events import Plugin
+
+DOT = '.'
+FLAGS = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_NDIFF
+TOPDIR = os.path.dirname(mailman.__file__)
+
+
+
+class NosePlugin(Plugin):
+ configSection = 'mailman'
+
+ def __init__(self):
+ self.patterns = []
+ self.addArgument(self.patterns, 'P', 'pattern',
+ 'Add a test matching pattern')
+
+ def startTestRun(self, event):
+ MockAndMonkeyLayer.testing_mode = True
+ ConfigLayer.enable_stderr()
+
+ def getTestCaseNames(self, event):
+ if len(self.patterns) == 0:
+ # No filter patterns, so everything should be tested.
+ return
+ names = filter(event.isTestMethod, dir(event.testCase))
+ for name in names:
+ for pattern in self.patterns:
+ if re.search(pattern, name):
+ break
+ else:
+ event.excludedNames.append(name)
+
+ def handleFile(self, event):
+ path = event.path[len(TOPDIR)+1:]
+ if len(self.patterns) > 0:
+ for pattern in self.patterns:
+ if re.search(pattern, path):
+ break
+ else:
+ # Skip this doctest.
+ return
+ base, ext = os.path.splitext(path)
+ if ext != '.rst':
+ return
+ # Look to see if the package defines a test layer, otherwise use the
+ # default layer. First turn the file system path into a dotted Python
+ # module path.
+ parent = os.path.dirname(path)
+ dotted = 'mailman.' + DOT.join(parent.split(os.path.sep))
+ try:
+ module = importlib.import_module(dotted)
+ except ImportError:
+ layer = SMTPLayer
+ else:
+ layer = getattr(module, 'layer', SMTPLayer)
+ suite = doctest.DocFileSuite(
+ path, package='mailman',
+ optionflags=FLAGS,
+ setUp=setup,
+ tearDown=teardown)
+ # Flatten the suite, adding the layer flag on every TestCase.
+ for test in suite:
+ test.layer = layer
+ event.extraTests.append(test)
=== added file 'unittest.cfg'
--- unittest.cfg 1970-01-01 00:00:00 +0000
+++ unittest.cfg 2013-08-26 15:55:35 +0000
@@ -0,0 +1,10 @@
+[unittest]
+verbose = 2
+plugins = mailman.testing.nose
+ nose2.plugins.layers
+
+[mailman]
+always-on = True
+
+[log-capture]
+always-on = False
_______________________________________________
Mailman-coders mailing list
[email protected]
http://mail.python.org/mailman/listinfo/mailman-coders