1
# Copyright (C) 2013 by the Free Software Foundation, Inc.
3
# This file is part of GNU Mailman.
5
# GNU Mailman is free software: you can redistribute it and/or modify it under
6
# the terms of the GNU General Public License as published by the Free
7
# Software Foundation, either version 3 of the License, or (at your option)
10
# GNU Mailman is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
15
# You should have received a copy of the GNU General Public License along with
16
# GNU Mailman. If not, see <http://www.gnu.org/licenses/>.
18
"""nose2 test infrastructure."""
20
from __future__ import absolute_import, print_function, unicode_literals
32
from mailman.testing.layers import ConfigLayer, MockAndMonkeyLayer
33
from nose2.events import Plugin
36
TOPDIR = os.path.dirname(mailman.__file__)
39
class NosePlugin(Plugin):
40
configSection = 'mailman'
44
self.addArgument(self.patterns, 'P', 'pattern',
45
'Add a test matching pattern')
47
def startTestRun(self, event):
48
MockAndMonkeyLayer.testing_mode = True
49
ConfigLayer.enable_stderr()
51
def getTestCaseNames(self, event):
52
if len(self.patterns) == 0:
53
# No filter patterns, so everything should be tested.
55
names = filter(event.isTestMethod, dir(event.testCase))
57
for pattern in self.patterns:
58
if re.search(pattern, name):
61
event.excludedNames.append(name)