def makeSuite(): """ Automatically create tests and test suites for all tests. For this to work, test modules must reside in MoinMoin._tests (i.e. right here) and have names starting with "test_", and contain test cases with names ending in "TestCase". Each test case may contain multiply testAABBCC methods. Those methods will be run by the test suites. See _test_template.py for an example, and use it to create new tests. """ result = unittest.TestSuite() test_modules = pysupport.getPackageModules(__file__) # Sort test modules names by case insensitive compare to get nicer output caseInsensitiveCompare = lambda a, b: cmp(a.lower(), b.lower()) test_modules.sort(caseInsensitiveCompare) for mod_name in test_modules: if not mod_name.startswith('test_'): continue # Import module module = __import__(__name__ + '.' + mod_name, globals(), locals(), ['__file__']) # Collect TestCase and create suite for each one test_cases = [unittest.makeSuite(obj, 'test') for name, obj in module.__dict__.items() if name.endswith('TestCase')] # Add tests suites if test_cases: suite = unittest.TestSuite(test_cases) result.addTest(suite) return result
def makeSuite(request, names=None): """ Create test suites from modules in names @param request: current request @param names: module names to get tests from. If the list is empty, all test modules in the _tests package are used. @rtype: C{unittest.TestSuite} @return: test suite with all test cases in names """ if not names: from MoinMoin.util.pysupport import getPackageModules names = getPackageModules(__file__) names = ['%s.%s' % (__name__, name) for name in names if name.startswith('test_')] caseInsensitiveCompare = lambda a, b: cmp(a.lower(), b.lower()) names.sort(caseInsensitiveCompare) loader = MoinTestLoader(request) return loader.loadTestsFromNames(names)
# -*- coding: iso-8859-1 -*- """ MoinMoin - Extension Script Package @copyright: 2006 by Thomas Waldmann @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport # create a list of extension scripts from the subpackage directory extension_scripts = pysupport.getPackageModules(__file__) modules = extension_scripts
# -*- coding: iso-8859-1 -*- """ MoinMoin - Processor Package DEPRECATED! Please use Parsers instead of Processors. @copyright: 2002 by Jürgen Hermann <*****@*****.**> @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport import MoinMoin.request processors = pysupport.getPackageModules(MoinMoin.request.prefix + "/processor/__init__.py") modules = processors
This code abstracts event handling in MoinMoin, currently for notifications. It implements the observer pattern. @copyright: 2007 by Karol Nowak <*****@*****.**> @license: GNU GPL, see COPYING for details. """ from MoinMoin import log logging = log.getLogger(__name__) from MoinMoin import wikiutil from MoinMoin.util import pysupport from MoinMoin.wikiutil import PluginAttributeError # Create a list of extension actions from the package directory modules = pysupport.getPackageModules(__file__) # Dummy pseudo-getText function used in event descriptions, # so that they get into .po files _ = lambda x: x class Event(object): """A class handling information common to all events.""" # NOTE: each Event subclass must have a unique name attribute name = u"Event" def __init__(self, request): self.request = request
# -*- coding: iso-8859-1 -*- """ MoinMoin - Maintenance Script Package @copyright: 2006 MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport # create a list of extension scripts from the subpackage directory maint_scripts = pysupport.getPackageModules(__file__) modules = maint_scripts
# -*- coding: iso-8859-1 -*- """ MoinMoin - Parser Package See "plain.py" for the most simple parser that also defines the parser interface. @copyright: 2000 by Jürgen Hermann <*****@*****.**> @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport import MoinMoin.request modules = pysupport.getPackageModules(MoinMoin.request.prefix + "/parser/__init__.py")
# -*- coding: iso-8859-1 -*- """ MoinMoin - Macro Package The canonical interface to macros is their execute() function, which gets passed an instance of the Macro class. Such an instance has the four members parser, formatter, form and request. Using "form" directly is deprecated and should be replaced by "request.form". Besides the execute() function, macros can export additional functions to offer services to other macros or actions. A few actually do that, e.g. AttachFile. @copyright: 2000 by Jürgen Hermann <*****@*****.**> @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport import MoinMoin.request extension_macros = pysupport.getPackageModules(MoinMoin.request.prefix + "/macro/__init__.py") modules = extension_macros
# -*- coding: iso-8859-1 -*- """ MoinMoin - Migration Script Package @copyright: 2006 MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport # create a list of extension scripts from the subpackage directory migration_scripts = pysupport.getPackageModules(__file__) modules = migration_scripts
# -*- coding: iso-8859-1 -*- """ MoinMoin - Processor Package DEPRECATED! Please use Parsers instead of Processors. @copyright: 2002 by Jürgen Hermann <*****@*****.**> @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport processors = pysupport.getPackageModules(__file__) modules = processors
def getPlugins(request): dir = os.path.join(request.cfg.plugin_dir, 'action') plugins = [] if os.path.isdir(dir): plugins = pysupport.getPackageModules(os.path.join(dir, 'dummy')) return dir, plugins
# -*- coding: iso-8859-1 -*- """ MoinMoin - Extension Converter Package @copyright: 2006 MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport # create a list of extension converters from the subpackage directory import MoinMoin.request extension_converters = pysupport.getPackageModules(MoinMoin.request.prefix + "/converter/__init__.py") modules = extension_converters
# -*- coding: iso-8859-1 -*- """ MoinMoin - LogFile package @copyright: 2005 by Thomas Waldmann (MoinMoin:ThomasWaldmann) @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport import MoinMoin.request logfiles = pysupport.getPackageModules(MoinMoin.request.prefix + "/logfile/__init__.py")
# -*- coding: iso-8859-1 -*- """ MoinMoin - Maintenance Script Package @copyright: 2006 by Thomas Waldmann @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport # create a list of extension scripts from the subpackage directory maint_scripts = pysupport.getPackageModules(__file__) modules = maint_scripts
# -*- coding: iso-8859-1 -*- """ MoinMoin - Migration Script Package @copyright: 2006 by Thomas Waldmann @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport # create a list of extension scripts from the subpackage directory migration_scripts = pysupport.getPackageModules(__file__) modules = migration_scripts
Additionally to the usual stuff, we provide an ActionBase class here with some of the usual base functionality for an action, like checking actions_excluded, making and checking tickets, rendering some form, displaying errors and doing stuff after an action. @copyright: 2006 MoinMoin:ThomasWaldmann @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport from MoinMoin import wikiutil from MoinMoin.Page import Page # create a list of extension actions from the subpackage directory import MoinMoin.request extension_actions = pysupport.getPackageModules(MoinMoin.request.prefix + "/action/__init__.py") modules = extension_actions class ActionBase: """ action base class with some generic stuff to inherit Note: the action name is the class name of the derived class """ def __init__(self, pagename, request): self.request = request self.form = request.form self.cfg = request.cfg self._ = _ = request.getText self.pagename = pagename self.actionname = self.__class__.__name__ self.use_ticket = False # set this to True if you want to use a ticket
# -*- coding: iso-8859-1 -*- """ MoinMoin - Macro Package The canonical interface to macros is their execute() function, which gets passed an instance of the Macro class. Such an instance has the four members parser, formatter, form and request. Using "form" directly is deprecated and should be replaced by "request.form". Besides the execute() function, macros can export additional functions to offer services to other macros or actions. A few actually do that, e.g. AttachFile. @copyright: 2000 by Jürgen Hermann <*****@*****.**> @license: GNU GPL, see COPYING for details. """ from MoinMoin.util import pysupport extension_macros = pysupport.getPackageModules(__file__) modules = extension_macros