From e1aa6efdff4542238af6abc96c848d8eda993787 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Thu, 26 Aug 2004 05:05:01 +0000 Subject: [PATCH] Better fix for the bugs induced by this new firewall thing. --- test/test_Note.py | 1 + test/test_RootWarner.py | 11 ++--------- test/testsupport.py | 17 +++++++++++++++++ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/test/test_Note.py b/test/test_Note.py index 1b4d75e21..f15fd6b05 100644 --- a/test/test_Note.py +++ b/test/test_Note.py @@ -36,6 +36,7 @@ import supybot.ircdb as ircdb class NoteTestCase(PluginTestCase, PluginDocumentation): plugins = ('Note', 'Misc', 'User') + config = {'supybot.reply.whenNotCommand': False} def setUp(self): PluginTestCase.setUp(self) # setup a user diff --git a/test/test_RootWarner.py b/test/test_RootWarner.py index da8f66745..f5cd4152d 100644 --- a/test/test_RootWarner.py +++ b/test/test_RootWarner.py @@ -33,15 +33,8 @@ from testsupport import * class RootWarnerTestCase(PluginTestCase): plugins = ('RootWarner',) - def setUp(self): - 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) - + config = {'supybot.reply.whenNotCommand': False} + def test(self): self.irc.feedMsg(ircmsgs.join('#foo', prefix='foo!root@host')) self.assertNotError(' ') diff --git a/test/testsupport.py b/test/testsupport.py index f5dc94d00..4f972c48a 100644 --- a/test/testsupport.py +++ b/test/testsupport.py @@ -51,6 +51,7 @@ world.startedAt = started import supybot.irclib as irclib import supybot.drivers as drivers import supybot.ircmsgs as ircmsgs +import supybot.registry as registry import supybot.ircutils as ircutils import supybot.callbacks as callbacks @@ -122,6 +123,11 @@ class PluginTestCase(SupyTestCase): plugins = None cleanConfDir = True cleanDataDir = True + config = {} + def __init__(self, *args, **kwargs): + SupyTestCase.__init__(self, *args, **kwargs) + self.originals = {} + def setUp(self, nick='test'): if self.__class__ in (PluginTestCase, ChannelPluginTestCase): # Necessary because there's a test in here that shouldn\'t run. @@ -173,11 +179,22 @@ class PluginTestCase(SupyTestCase): except Owner.Deprecated, e: return utils.exnToString(e) 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): if self.__class__ in (PluginTestCase, ChannelPluginTestCase): # Necessary because there's a test in here that shouldn\'t run. return + for (group, original) in self.originals.iteritems(): + group.setValue(original) ircdb.users.close() ircdb.ignores.close() ircdb.channels.close()