mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 11:12:47 +01:00
Resurrected the test suite with the new supybot-test program and RCS.
This commit is contained in:
parent
3d3b1498fe
commit
895cd3e48e
@ -163,16 +163,21 @@ if __name__ == '__main__':
|
||||
pluginDirs = set([os.path.dirname(s) or '.' for s in args])
|
||||
conf.supybot.directories.plugins.setValue(list(pluginDirs))
|
||||
pluginNames = set([os.path.basename(s) for s in args])
|
||||
suites = []
|
||||
load = unittest.defaultTestLoader.loadTestsFromModule
|
||||
for pluginName in pluginNames:
|
||||
if pluginName.endswith('.py'):
|
||||
pluginName = pluginName[:-3]
|
||||
try:
|
||||
pluginModule = plugin.loadPluginModule(pluginName)
|
||||
except ImportError, e:
|
||||
sys.stderr.write('Failed to load plugin %s: %s\n' % (pluginName,e))
|
||||
sys.stderr.write('(pluginDirs: %s)' %
|
||||
conf.supybot.directories.plugins())
|
||||
sys.exit(-1)
|
||||
if hasattr(pluginModule, 'test'):
|
||||
suites.append(load(pluginModule.test))
|
||||
test.suites.append(load(pluginModule.test))
|
||||
|
||||
suite = unittest.TestSuite(suites)
|
||||
suite = unittest.TestSuite(test.suites)
|
||||
runner = unittest.TextTestRunner(verbosity=2)
|
||||
runner.run(suite)
|
||||
|
||||
|
@ -53,6 +53,9 @@ import supybot.callbacks as callbacks
|
||||
|
||||
network = True
|
||||
|
||||
# This is the global list of suites that are to be run.
|
||||
suites = []
|
||||
|
||||
originalCallbacksGetHelp = callbacks.getHelp
|
||||
lastGetHelp = 'x'*1000
|
||||
def cachingGetHelp(method, name=None):
|
||||
|
32
test/__init__.py
Normal file
32
test/__init__.py
Normal file
@ -0,0 +1,32 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import test
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
48
test/test.py
Normal file
48
test/test.py
Normal file
@ -0,0 +1,48 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
import os.path
|
||||
import unittest
|
||||
|
||||
import supybot.test as test
|
||||
|
||||
load = unittest.defaultTestLoader.loadTestsFromModule
|
||||
|
||||
GLOBALS = globals()
|
||||
dirname = os.path.dirname(__file__)
|
||||
for filename in os.listdir(dirname):
|
||||
if filename.startswith('test_') and filename.endswith('.py'):
|
||||
name = filename[:-3]
|
||||
exec 'import %s' % name in GLOBALS
|
||||
test.suites.append(load(GLOBALS[name]))
|
||||
|
||||
module = None
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import supybot.conf as conf
|
||||
import supybot.utils as utils
|
||||
@ -272,7 +272,7 @@ class FunctionsTestCase(SupyTestCase):
|
||||
|
||||
|
||||
class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
plugins = ('Utilities', 'Misc', 'Http')
|
||||
plugins = ('Utilities', 'Misc',)
|
||||
conf.allowEval = True
|
||||
timeout = 2
|
||||
def testEmptySquareBrackets(self):
|
||||
@ -280,6 +280,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
||||
|
||||
def testHelpNoNameError(self):
|
||||
# This will raise a NameError if some dynamic scoping isn't working
|
||||
self.assertNotError('load Http')
|
||||
self.assertHelp('extension')
|
||||
|
||||
def testMaximumNestingDepth(self):
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
from supybot.commands import *
|
||||
import supybot.irclib as irclib
|
||||
|
@ -29,7 +29,7 @@
|
||||
|
||||
## from __future__ import generators
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import random
|
||||
import itertools
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import os
|
||||
import unittest
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import copy
|
||||
import pickle
|
||||
@ -36,6 +36,11 @@ import supybot.conf as conf
|
||||
import supybot.irclib as irclib
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
|
||||
# The test framework used to provide these, but not it doesn't. We'll add
|
||||
# messages to as we find bugs (if indeed we find bugs).
|
||||
msgs = []
|
||||
rawmsgs = []
|
||||
|
||||
class IrcMsgQueueTestCase(SupyTestCase):
|
||||
mode = ircmsgs.op('#foo', 'jemfinch')
|
||||
msg = ircmsgs.privmsg('#foo', 'hey, you')
|
||||
@ -226,22 +231,24 @@ class IrcStateTestCase(SupyTestCase):
|
||||
self.failUnless(st.channels['#foo'].isOp('baz'))
|
||||
|
||||
def testHistory(self):
|
||||
oldconfmaxhistory = conf.supybot.protocols.irc.maxHistoryLength()
|
||||
conf.supybot.protocols.irc.maxHistoryLength.setValue(10)
|
||||
if len(msgs) < 10:
|
||||
return
|
||||
maxHistoryLength = conf.supybot.protocols.irc.maxHistoryLength
|
||||
oldconfmaxhistory = maxHistoryLength()
|
||||
try:
|
||||
maxHistoryLength.setValue(10)
|
||||
state = irclib.IrcState()
|
||||
for msg in msgs:
|
||||
try:
|
||||
state.addMsg(self.irc, msg)
|
||||
except Exception:
|
||||
pass
|
||||
self.failIf(len(state.history) >
|
||||
conf.supybot.protocols.irc.maxHistoryLength())
|
||||
self.assertEqual(len(state.history),
|
||||
conf.supybot.protocols.irc.maxHistoryLength())
|
||||
self.failIf(len(state.history) > maxHistoryLength())
|
||||
self.assertEqual(len(state.history), maxHistoryLength())
|
||||
self.assertEqual(list(state.history),
|
||||
msgs[len(msgs) -
|
||||
conf.supybot.protocols.irc.maxHistoryLength():])
|
||||
conf.supybot.protocols.irc.maxHistoryLength.setValue(oldconfmaxhistory)
|
||||
msgs[len(msgs) - maxHistoryLength():])
|
||||
finally:
|
||||
maxHistoryLength.setValue(oldconfmaxhistory)
|
||||
|
||||
def testWasteland005(self):
|
||||
state = irclib.IrcState()
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import copy
|
||||
import pickle
|
||||
@ -35,6 +35,10 @@ import pickle
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.ircutils as ircutils
|
||||
|
||||
# The test framework used to provide these, but not it doesn't. We'll add
|
||||
# messages to as we find bugs (if indeed we find bugs).
|
||||
msgs = []
|
||||
rawmsgs = []
|
||||
|
||||
class IrcMsgTestCase(SupyTestCase):
|
||||
def testLen(self):
|
||||
@ -59,7 +63,7 @@ class IrcMsgTestCase(SupyTestCase):
|
||||
def testEq(self):
|
||||
for msg in msgs:
|
||||
self.assertEqual(msg, msg)
|
||||
self.failIf(msgs[0] == []) # Comparison to unhashable type.
|
||||
self.failIf(msgs and msgs[0] == []) # Comparison to unhashable type.
|
||||
|
||||
def testNe(self):
|
||||
for msg in msgs:
|
||||
|
@ -28,7 +28,7 @@
|
||||
###
|
||||
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import copy
|
||||
import random
|
||||
@ -36,6 +36,11 @@ import random
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.ircutils as ircutils
|
||||
|
||||
# The test framework used to provide these, but not it doesn't. We'll add
|
||||
# messages to as we find bugs (if indeed we find bugs).
|
||||
msgs = []
|
||||
rawmsgs = []
|
||||
|
||||
class FunctionsTestCase(SupyTestCase):
|
||||
hostmask = 'foo!bar@baz'
|
||||
def testHostmaskPatternEqual(self):
|
||||
|
41
test/test_plugin.py
Normal file
41
test/test_plugin.py
Normal file
@ -0,0 +1,41 @@
|
||||
###
|
||||
# Copyright (c) 2005, Jeremiah Fincher
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright notice,
|
||||
# this list of conditions, and the following disclaimer in the
|
||||
# documentation and/or other materials provided with the distribution.
|
||||
# * Neither the name of the author of this software nor the name of
|
||||
# contributors to this software may be used to endorse or promote products
|
||||
# derived from this software without specific prior written consent.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from supybot.test import *
|
||||
|
||||
import supybot.plugin as plugin
|
||||
|
||||
class FunctionsTestCase(SupyTestCase):
|
||||
def testLoadPluginModule(self):
|
||||
self.assertRaises(ImportError, plugin.loadPluginModule, 'asldj')
|
||||
self.failUnless(plugin.loadPluginModule('Owner'))
|
||||
self.failUnless(plugin.loadPluginModule('owner'))
|
||||
|
||||
|
||||
# vim:set shiftwidth=4 tabstop=8 expandtab textwidth=78:
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import sets
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import supybot.ircmsgs as ircmsgs
|
||||
import supybot.privmsgs as privmsgs
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import re
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import time
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import sets
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import pickle
|
||||
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
import sets
|
||||
|
||||
import supybot.utils as utils
|
||||
|
@ -27,7 +27,7 @@
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
###
|
||||
|
||||
from testsupport import *
|
||||
from supybot.test import *
|
||||
|
||||
import supybot.webutils as webutils
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user