Better fix for the bugs induced by this new firewall thing.

This commit is contained in:
Jeremy Fincher 2004-08-26 05:05:01 +00:00
parent 6381e2aef8
commit e1aa6efdff
3 changed files with 20 additions and 9 deletions

View File

@ -36,6 +36,7 @@ import supybot.ircdb as ircdb
class NoteTestCase(PluginTestCase, PluginDocumentation): class NoteTestCase(PluginTestCase, PluginDocumentation):
plugins = ('Note', 'Misc', 'User') plugins = ('Note', 'Misc', 'User')
config = {'supybot.reply.whenNotCommand': False}
def setUp(self): def setUp(self):
PluginTestCase.setUp(self) PluginTestCase.setUp(self)
# setup a user # setup a user

View File

@ -33,14 +33,7 @@ from testsupport import *
class RootWarnerTestCase(PluginTestCase): class RootWarnerTestCase(PluginTestCase):
plugins = ('RootWarner',) plugins = ('RootWarner',)
def setUp(self): config = {'supybot.reply.whenNotCommand': False}
PluginTestCase.setUp(self)
self.original = conf.supybot.reply.whenNotCommand()
conf.supybot.reply.whenNotCommand.setValue(False)
def tearDown(self):
PluginTestCase.tearDown(self)
conf.supybot.reply.whenNotCommand.setValue(self.original)
def test(self): def test(self):
self.irc.feedMsg(ircmsgs.join('#foo', prefix='foo!root@host')) self.irc.feedMsg(ircmsgs.join('#foo', prefix='foo!root@host'))

View File

@ -51,6 +51,7 @@ world.startedAt = started
import supybot.irclib as irclib import supybot.irclib as irclib
import supybot.drivers as drivers import supybot.drivers as drivers
import supybot.ircmsgs as ircmsgs import supybot.ircmsgs as ircmsgs
import supybot.registry as registry
import supybot.ircutils as ircutils import supybot.ircutils as ircutils
import supybot.callbacks as callbacks import supybot.callbacks as callbacks
@ -122,6 +123,11 @@ class PluginTestCase(SupyTestCase):
plugins = None plugins = None
cleanConfDir = True cleanConfDir = True
cleanDataDir = True cleanDataDir = True
config = {}
def __init__(self, *args, **kwargs):
SupyTestCase.__init__(self, *args, **kwargs)
self.originals = {}
def setUp(self, nick='test'): def setUp(self, nick='test'):
if self.__class__ in (PluginTestCase, ChannelPluginTestCase): if self.__class__ in (PluginTestCase, ChannelPluginTestCase):
# Necessary because there's a test in here that shouldn\'t run. # Necessary because there's a test in here that shouldn\'t run.
@ -173,11 +179,22 @@ class PluginTestCase(SupyTestCase):
except Owner.Deprecated, e: except Owner.Deprecated, e:
return utils.exnToString(e) return utils.exnToString(e)
cb = Owner.loadPluginClass(self.irc, module) cb = Owner.loadPluginClass(self.irc, module)
for (name, value) in self.config.iteritems():
group = conf.supybot
parts = registry.split(name)
if parts[0] == 'supybot':
parts.pop(0)
for part in parts:
group = group.get(part)
self.originals[group] = group()
group.setValue(value)
def tearDown(self): def tearDown(self):
if self.__class__ in (PluginTestCase, ChannelPluginTestCase): if self.__class__ in (PluginTestCase, ChannelPluginTestCase):
# Necessary because there's a test in here that shouldn\'t run. # Necessary because there's a test in here that shouldn\'t run.
return return
for (group, original) in self.originals.iteritems():
group.setValue(original)
ircdb.users.close() ircdb.users.close()
ircdb.ignores.close() ircdb.ignores.close()
ircdb.channels.close() ircdb.channels.close()