Made a SupyTestCase base class to handle COOL STUFF\!

This commit is contained in:
Jeremy Fincher 2004-02-16 04:12:35 +00:00
parent 5c660fd56e
commit 48d6c982ce
15 changed files with 35 additions and 27 deletions

View File

@ -33,7 +33,7 @@ from testsupport import *
Alias = Owner.loadPluginModule('Alias')
class FunctionsTest(unittest.TestCase):
class FunctionsTest(SupyTestCase):
def testFindAliasCommand(self):
s = 'command'
self.failIf(Alias.findAliasCommand(s, ''))

View File

@ -40,7 +40,7 @@ except ImportError:
if sqlite is not None:
MoobotFactoids = Owner.loadPluginModule('MoobotFactoids')
MF = MoobotFactoids
class OptionListTestCase(unittest.TestCase):
class OptionListTestCase(SupyTestCase):
def testPickOptions(self):
for i in xrange(10):
self.failUnless(MF.pickOptions('(a|b)') in ['a', 'b'])

View File

@ -94,7 +94,7 @@ class OwnerTestCase(PluginTestCase, PluginDocumentation):
self.assertNotError('unload ALIAS')
class FunctionsTestCase(unittest.TestCase):
class FunctionsTestCase(SupyTestCase):
def testLoadPluginModule(self):
self.assertRaises(ImportError, Owner.loadPluginModule, 'asldj')
self.failUnless(Owner.loadPluginModule('Owner'))

View File

@ -39,7 +39,7 @@ import callbacks
tokenize = callbacks.tokenize
class TokenizerTestCase(unittest.TestCase):
class TokenizerTestCase(SupyTestCase):
def testEmpty(self):
self.assertEqual(tokenize(''), [])
@ -115,7 +115,7 @@ class TokenizerTestCase(unittest.TestCase):
self.assertEqual(tokenize(s), [s])
class FunctionsTestCase(unittest.TestCase):
class FunctionsTestCase(SupyTestCase):
def testCanonicalName(self):
self.assertEqual('foo', callbacks.canonicalName('foo'))
self.assertEqual('foobar', callbacks.canonicalName('foo-bar'))

View File

@ -35,7 +35,7 @@ from testsupport import *
import itertools
class FunctionsTest(unittest.TestCase):
class FunctionsTest(SupyTestCase):
def testCatch(self):
def f():
raise Exception

View File

@ -39,14 +39,14 @@ import world
import ircdb
import ircutils
class IrcdbTestCase(unittest.TestCase):
class IrcdbTestCase(SupyTestCase):
def setUp(self):
world.testing = False
unittest.TestCase.setUp(self)
SupyTestCase.setUp(self)
def tearDown(self):
world.testing = True
unittest.TestCase.tearDown(self)
SupyTestCase.tearDown(self)
class FunctionsTestCase(IrcdbTestCase):
def testIsAntiCapability(self):
@ -91,7 +91,7 @@ class FunctionsTestCase(IrcdbTestCase):
self.assertEqual(ircdb.invertCapability('#foo,-bar'), '#foo,bar')
class CapabilitySetTestCase(unittest.TestCase):
class CapabilitySetTestCase(SupyTestCase):
def testGeneral(self):
d = ircdb.CapabilitySet()
self.assertRaises(KeyError, d.check, 'foo')
@ -161,7 +161,7 @@ class CapabilitySetTestCase(unittest.TestCase):
self.failIf(s.check('-foo'))
class UserCapabilitySetTestCase(unittest.TestCase):
class UserCapabilitySetTestCase(SupyTestCase):
def testOwnerHasAll(self):
d = ircdb.UserCapabilitySet(('owner',))
self.failIf(d.check('-foo'))

View File

@ -38,7 +38,7 @@ import ircmsgs
import ircutils
class IrcMsgTestCase(unittest.TestCase):
class IrcMsgTestCase(SupyTestCase):
def testLen(self):
for msg in msgs:
if msg.prefix:
@ -115,7 +115,7 @@ class IrcMsgTestCase(unittest.TestCase):
self.assertRaises(ircmsgs.MalformedIrcMsg, ircmsgs.IrcMsg,
args=('biff',), prefix='foo!bar@baz')
class FunctionsTestCase(unittest.TestCase):
class FunctionsTestCase(SupyTestCase):
def testIsAction(self):
L = [':jemfinch!~jfincher@ts26-2.homenet.ohio-state.edu PRIVMSG'
' #sourcereview :ACTION does something',

View File

@ -39,7 +39,7 @@ import plugins
class holder:
users = sets.Set(map(str, range(1000)))
class FunctionsTestCase(unittest.TestCase):
class FunctionsTestCase(SupyTestCase):
class irc:
class state:
channels = {'#foo': holder()}

View File

@ -35,7 +35,7 @@ import ircmsgs
import privmsgs
import callbacks
class FunctionsTest(unittest.TestCase):
class FunctionsTest(SupyTestCase):
def testGetChannel(self):
channel = '#foo'
msg = ircmsgs.privmsg(channel, 'foo bar baz')

View File

@ -36,7 +36,7 @@ import re
import conf
import registry
class ValuesTestCase(unittest.TestCase):
class ValuesTestCase(SupyTestCase):
def testBoolean(self):
v = registry.Boolean(True, """Help""")
self.failUnless(v())

View File

@ -35,7 +35,7 @@ import time
import schedule
class TestSchedule(unittest.TestCase):
class TestSchedule(SupyTestCase):
def testSchedule(self):
sched = schedule.Schedule()
i = [0]

View File

@ -35,7 +35,7 @@ import pickle
from structures import *
class RingBufferTestCase(unittest.TestCase):
class RingBufferTestCase(SupyTestCase):
def testInit(self):
self.assertRaises(ValueError, RingBuffer, -1)
self.assertRaises(ValueError, RingBuffer, 0)
@ -198,7 +198,7 @@ class RingBufferTestCase(unittest.TestCase):
self.assertEqual(L, range(3))
class QueueTest(unittest.TestCase):
class QueueTest(SupyTestCase):
def testReset(self):
q = queue()
q.enqueue(1)
@ -363,7 +363,7 @@ class QueueTest(unittest.TestCase):
queue = smallqueue
class SmallQueueTest(unittest.TestCase):
class SmallQueueTest(SupyTestCase):
def testReset(self):
q = queue()
q.enqueue(1)
@ -527,7 +527,7 @@ class SmallQueueTest(unittest.TestCase):
self.assertEqual(q, pickle.loads(pickle.dumps(q)))
class MaxLengthQueueTestCase(unittest.TestCase):
class MaxLengthQueueTestCase(SupyTestCase):
def testInit(self):
q = MaxLengthQueue(3, (1, 2, 3))
self.assertEqual(list(q), [1, 2, 3])
@ -549,7 +549,7 @@ class MaxLengthQueueTestCase(unittest.TestCase):
self.assertEqual(q[0], 3)
class TwoWayDictionaryTestCase(unittest.TestCase):
class TwoWayDictionaryTestCase(SupyTestCase):
def testInit(self):
d = TwoWayDictionary(foo='bar')
self.failUnless('foo' in d)
@ -576,7 +576,7 @@ class TwoWayDictionaryTestCase(unittest.TestCase):
self.failIf('foo' in d)
class PersistentDictionaryTestCase(unittest.TestCase):
class PersistentDictionaryTestCase(SupyTestCase):
def test(self):
d = PersistentDictionary('test.dict')
d['foo'] = 'bar'

View File

@ -34,7 +34,7 @@ import sets
import utils
class UtilsTest(unittest.TestCase):
class UtilsTest(SupyTestCase):
def testMatchCase(self):
f = utils.matchCase
self.assertEqual('bar', f('foo', 'bar'))

View File

@ -34,7 +34,7 @@ from testsupport import *
import webutils
class WebutilsTestCase(unittest.TestCase):
class WebutilsTestCase(SupyTestCase):
def testGetDomain(self):
self.assertEqual(webutils.getDomain('http://slashdot.org/foo/bar.exe'),
'slashdot.org')

View File

@ -39,6 +39,7 @@ import time
started = time.time()
import unittest
import log
import conf
import utils
import ircdb
@ -99,7 +100,13 @@ class TimeoutError(AssertionError):
def __str__(self):
return '%r timed out' % self.args[0]
class PluginTestCase(unittest.TestCase):
class SupyTestCase(unittest.TestCase):
def setUp(self):
log.critical('Beginning test case %s', self.id())
unittest.TestCase.setUp(self)
class PluginTestCase(SupyTestCase):
"""Subclass this to write a test case for a plugin. See test/test_Fun.py
for an example.
"""
@ -108,10 +115,11 @@ class PluginTestCase(unittest.TestCase):
cleanConfDir = True
cleanDataDir = True
def setUp(self, nick='test'):
# Set conf variables appropriately.
if self.__class__ in (PluginTestCase, ChannelPluginTestCase):
# Necessary because there's a test in here that shouldn\'t run.
return
SupyTestCase.setUp(self)
# Set conf variables appropriately.
conf.supybot.prefixChars.set('@')
conf.supybot.reply.whenNotCommand.setValue(False)
self.myVerbose = world.myVerbose