summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBarry Warsaw2016-11-29 19:58:16 -0500
committerBarry Warsaw2016-11-29 19:58:16 -0500
commitcdd24f88bd36aa2bd87252618e98b80aa7cc1bf1 (patch)
treed1d79f8a2eceebf3799512812bc58da06b3b4cfd
parent5d73d057854191637b248da0875cf7ce005bbffb (diff)
downloadmailman-cdd24f88bd36aa2bd87252618e98b80aa7cc1bf1.tar.gz
mailman-cdd24f88bd36aa2bd87252618e98b80aa7cc1bf1.tar.zst
mailman-cdd24f88bd36aa2bd87252618e98b80aa7cc1bf1.zip
-rw-r--r--setup.py1
-rw-r--r--src/mailman/core/system.py3
-rw-r--r--src/mailman/testing/nose.py118
-rw-r--r--unittest.cfg5
4 files changed, 7 insertions, 120 deletions
diff --git a/setup.py b/setup.py
index 378bc989a..c31817b9a 100644
--- a/setup.py
+++ b/setup.py
@@ -110,6 +110,7 @@ case second `m'. Any other spelling is incorrect.""",
'flufl.bounce',
'flufl.i18n',
'flufl.lock',
+ 'flufl.testing',
'httplib2',
'lazr.config',
'nose2',
diff --git a/src/mailman/core/system.py b/src/mailman/core/system.py
index 2d76f0c97..41ddced95 100644
--- a/src/mailman/core/system.py
+++ b/src/mailman/core/system.py
@@ -19,8 +19,9 @@
import sys
+from mailman import version
from mailman.interfaces.system import ISystem
-from public import public, version
+from public import public
from zope.interface import implementer
diff --git a/src/mailman/testing/nose.py b/src/mailman/testing/nose.py
deleted file mode 100644
index 1a9830da5..000000000
--- a/src/mailman/testing/nose.py
+++ /dev/null
@@ -1,118 +0,0 @@
-# Copyright (C) 2013-2016 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."""
-
-import os
-import re
-import doctest
-import importlib
-
-from mailman.testing.documentation import setup, teardown
-from mailman.testing.layers import ConfigLayer, MockAndMonkeyLayer, SMTPLayer
-from nose2.events import Plugin
-from pkg_resources import resource_filename
-from public import public
-
-
-DOT = '.'
-FLAGS = doctest.ELLIPSIS | doctest.NORMALIZE_WHITESPACE | doctest.REPORT_NDIFF
-TOPDIR = os.path.dirname(resource_filename('mailman', '__init__.py'))
-
-
-@public
-class NosePlugin(Plugin):
- configSection = 'mailman'
-
- def __init__(self):
- super().__init__()
- self.patterns = []
- self.stderr = False
- def set_stderr(ignore): # noqa: E306
- self.stderr = True
- self.addArgument(self.patterns, 'P', 'pattern',
- 'Add a test matching pattern')
- self.addFlag(set_stderr, 'E', 'stderr',
- 'Enable stderr logging to sub-runners')
-
- def startTestRun(self, event):
- MockAndMonkeyLayer.testing_mode = True
- if (self.stderr or
- len(os.environ.get('MM_VERBOSE_TESTLOG', '').strip()) > 0):
- ConfigLayer.stderr = True
-
- def getTestCaseNames(self, event):
- if len(self.patterns) == 0:
- # No filter patterns, so everything should be tested.
- return
- # Does the pattern match the fully qualified class name?
- for pattern in self.patterns:
- full_class_name = '{}.{}'.format(
- event.testCase.__module__, event.testCase.__name__)
- if re.search(pattern, full_class_name):
- # Don't suppress this test class.
- return
- names = filter(event.isTestMethod, dir(event.testCase))
- for name in names:
- full_test_name = '{}.{}.{}'.format(
- event.testCase.__module__,
- event.testCase.__name__,
- name)
- for pattern in self.patterns:
- if re.search(pattern, full_test_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)
- test = doctest.DocFileTest(
- path, package='mailman',
- optionflags=FLAGS,
- setUp=setup,
- tearDown=teardown)
- test.layer = layer
- # Suppress the extra "Doctest: ..." line.
- test.shortDescription = lambda: None
- event.extraTests.append(test)
-
- # def startTest(self, event):
- # import sys; print('vvvvv', event.test, file=sys.stderr)
-
- # def stopTest(self, event):
- # import sys; print('^^^^^', event.test, file=sys.stderr)
diff --git a/unittest.cfg b/unittest.cfg
index d639a8ae3..4b080f22e 100644
--- a/unittest.cfg
+++ b/unittest.cfg
@@ -1,6 +1,6 @@
[unittest]
verbose = 2
-plugins = mailman.testing.nose
+plugins = flufl.testing.nose
nose2.plugins.layers
[mailman]
@@ -8,3 +8,6 @@ always-on = True
[log-capture]
always-on = False
+
+[flufl.testing]
+package = mailman