mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-12-23 19:22:45 +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])
|
pluginDirs = set([os.path.dirname(s) or '.' for s in args])
|
||||||
conf.supybot.directories.plugins.setValue(list(pluginDirs))
|
conf.supybot.directories.plugins.setValue(list(pluginDirs))
|
||||||
pluginNames = set([os.path.basename(s) for s in args])
|
pluginNames = set([os.path.basename(s) for s in args])
|
||||||
suites = []
|
|
||||||
load = unittest.defaultTestLoader.loadTestsFromModule
|
load = unittest.defaultTestLoader.loadTestsFromModule
|
||||||
for pluginName in pluginNames:
|
for pluginName in pluginNames:
|
||||||
if pluginName.endswith('.py'):
|
if pluginName.endswith('.py'):
|
||||||
pluginName = pluginName[:-3]
|
pluginName = pluginName[:-3]
|
||||||
|
try:
|
||||||
pluginModule = plugin.loadPluginModule(pluginName)
|
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'):
|
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 = unittest.TextTestRunner(verbosity=2)
|
||||||
runner.run(suite)
|
runner.run(suite)
|
||||||
|
|
||||||
|
@ -53,6 +53,9 @@ import supybot.callbacks as callbacks
|
|||||||
|
|
||||||
network = True
|
network = True
|
||||||
|
|
||||||
|
# This is the global list of suites that are to be run.
|
||||||
|
suites = []
|
||||||
|
|
||||||
originalCallbacksGetHelp = callbacks.getHelp
|
originalCallbacksGetHelp = callbacks.getHelp
|
||||||
lastGetHelp = 'x'*1000
|
lastGetHelp = 'x'*1000
|
||||||
def cachingGetHelp(method, name=None):
|
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.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import supybot.conf as conf
|
import supybot.conf as conf
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
@ -272,7 +272,7 @@ class FunctionsTestCase(SupyTestCase):
|
|||||||
|
|
||||||
|
|
||||||
class PrivmsgTestCase(ChannelPluginTestCase):
|
class PrivmsgTestCase(ChannelPluginTestCase):
|
||||||
plugins = ('Utilities', 'Misc', 'Http')
|
plugins = ('Utilities', 'Misc',)
|
||||||
conf.allowEval = True
|
conf.allowEval = True
|
||||||
timeout = 2
|
timeout = 2
|
||||||
def testEmptySquareBrackets(self):
|
def testEmptySquareBrackets(self):
|
||||||
@ -280,6 +280,7 @@ class PrivmsgTestCase(ChannelPluginTestCase):
|
|||||||
|
|
||||||
def testHelpNoNameError(self):
|
def testHelpNoNameError(self):
|
||||||
# This will raise a NameError if some dynamic scoping isn't working
|
# This will raise a NameError if some dynamic scoping isn't working
|
||||||
|
self.assertNotError('load Http')
|
||||||
self.assertHelp('extension')
|
self.assertHelp('extension')
|
||||||
|
|
||||||
def testMaximumNestingDepth(self):
|
def testMaximumNestingDepth(self):
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
from supybot.commands import *
|
from supybot.commands import *
|
||||||
import supybot.irclib as irclib
|
import supybot.irclib as irclib
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
|
|
||||||
## from __future__ import generators
|
## from __future__ import generators
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import random
|
import random
|
||||||
import itertools
|
import itertools
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import unittest
|
import unittest
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import pickle
|
import pickle
|
||||||
@ -36,6 +36,11 @@ import supybot.conf as conf
|
|||||||
import supybot.irclib as irclib
|
import supybot.irclib as irclib
|
||||||
import supybot.ircmsgs as ircmsgs
|
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):
|
class IrcMsgQueueTestCase(SupyTestCase):
|
||||||
mode = ircmsgs.op('#foo', 'jemfinch')
|
mode = ircmsgs.op('#foo', 'jemfinch')
|
||||||
msg = ircmsgs.privmsg('#foo', 'hey, you')
|
msg = ircmsgs.privmsg('#foo', 'hey, you')
|
||||||
@ -226,22 +231,24 @@ class IrcStateTestCase(SupyTestCase):
|
|||||||
self.failUnless(st.channels['#foo'].isOp('baz'))
|
self.failUnless(st.channels['#foo'].isOp('baz'))
|
||||||
|
|
||||||
def testHistory(self):
|
def testHistory(self):
|
||||||
oldconfmaxhistory = conf.supybot.protocols.irc.maxHistoryLength()
|
if len(msgs) < 10:
|
||||||
conf.supybot.protocols.irc.maxHistoryLength.setValue(10)
|
return
|
||||||
|
maxHistoryLength = conf.supybot.protocols.irc.maxHistoryLength
|
||||||
|
oldconfmaxhistory = maxHistoryLength()
|
||||||
|
try:
|
||||||
|
maxHistoryLength.setValue(10)
|
||||||
state = irclib.IrcState()
|
state = irclib.IrcState()
|
||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
try:
|
try:
|
||||||
state.addMsg(self.irc, msg)
|
state.addMsg(self.irc, msg)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
self.failIf(len(state.history) >
|
self.failIf(len(state.history) > maxHistoryLength())
|
||||||
conf.supybot.protocols.irc.maxHistoryLength())
|
self.assertEqual(len(state.history), maxHistoryLength())
|
||||||
self.assertEqual(len(state.history),
|
|
||||||
conf.supybot.protocols.irc.maxHistoryLength())
|
|
||||||
self.assertEqual(list(state.history),
|
self.assertEqual(list(state.history),
|
||||||
msgs[len(msgs) -
|
msgs[len(msgs) - maxHistoryLength():])
|
||||||
conf.supybot.protocols.irc.maxHistoryLength():])
|
finally:
|
||||||
conf.supybot.protocols.irc.maxHistoryLength.setValue(oldconfmaxhistory)
|
maxHistoryLength.setValue(oldconfmaxhistory)
|
||||||
|
|
||||||
def testWasteland005(self):
|
def testWasteland005(self):
|
||||||
state = irclib.IrcState()
|
state = irclib.IrcState()
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import pickle
|
import pickle
|
||||||
@ -35,6 +35,10 @@ import pickle
|
|||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.ircutils as ircutils
|
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):
|
class IrcMsgTestCase(SupyTestCase):
|
||||||
def testLen(self):
|
def testLen(self):
|
||||||
@ -59,7 +63,7 @@ class IrcMsgTestCase(SupyTestCase):
|
|||||||
def testEq(self):
|
def testEq(self):
|
||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
self.assertEqual(msg, msg)
|
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):
|
def testNe(self):
|
||||||
for msg in msgs:
|
for msg in msgs:
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
###
|
###
|
||||||
|
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
import random
|
import random
|
||||||
@ -36,6 +36,11 @@ import random
|
|||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.ircutils as ircutils
|
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):
|
class FunctionsTestCase(SupyTestCase):
|
||||||
hostmask = 'foo!bar@baz'
|
hostmask = 'foo!bar@baz'
|
||||||
def testHostmaskPatternEqual(self):
|
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.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import sets
|
import sets
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import supybot.ircmsgs as ircmsgs
|
import supybot.ircmsgs as ircmsgs
|
||||||
import supybot.privmsgs as privmsgs
|
import supybot.privmsgs as privmsgs
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import sets
|
import sets
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
import sets
|
import sets
|
||||||
|
|
||||||
import supybot.utils as utils
|
import supybot.utils as utils
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
###
|
###
|
||||||
|
|
||||||
from testsupport import *
|
from supybot.test import *
|
||||||
|
|
||||||
import supybot.webutils as webutils
|
import supybot.webutils as webutils
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user