diff --git a/plugins/RSS/test.py b/plugins/RSS/test.py index d14eb6316..a7e39dd03 100644 --- a/plugins/RSS/test.py +++ b/plugins/RSS/test.py @@ -63,6 +63,9 @@ def constant(content): url = 'http://www.advogato.org/rss/articles.xml' class RSSTestCase(ChannelPluginTestCase): plugins = ('RSS','Plugin') + + timeout = 1 + def testRssAddBadName(self): self.assertError('rss add "foo bar" %s' % url) @@ -340,6 +343,8 @@ class RSSTestCase(ChannelPluginTestCase): feedparser._open_resource = old_open if network: + timeout = 5 # Note this applies also to the above tests + def testRssinfo(self): timeFastForward(1.1) self.assertNotError('rss info %s' % url) diff --git a/plugins/SedRegex/test.py b/plugins/SedRegex/test.py index 87ddea73f..0c70f8f31 100644 --- a/plugins/SedRegex/test.py +++ b/plugins/SedRegex/test.py @@ -42,7 +42,7 @@ class SedRegexTestCase(ChannelPluginTestCase): # getMsg() stalls if no message is ever sent (i.e. if the plugin fails to respond to a request) # We should limit the timeout to prevent the tests from taking forever. - timeout = 3 + timeout = 1 def testSimpleReplace(self): self.feedMsg('Abcd abcdefgh') diff --git a/src/test.py b/src/test.py index 34765f108..011fa668c 100644 --- a/src/test.py +++ b/src/test.py @@ -196,8 +196,10 @@ class PluginTestCase(SupyTestCase): cleanConfDir = True cleanDataDir = True config = {} + timeout = None def __init__(self, methodName='runTest'): - self.timeout = timeout + if self.timeout is None: + self.timeout = timeout originalRunTest = getattr(self, methodName) def runTest(self): run = True @@ -373,12 +375,23 @@ class PluginTestCase(SupyTestCase): '%s is not the help (%s)' % (m.args[1], lastGetHelp)) return m - def assertNoResponse(self, query, timeout=0, **kwargs): + def assertNoResponse(self, query, timeout=None, **kwargs): + if timeout is None: + timeout = 0 + # timeout=0 does not wait at all for an answer after the command + # function finished running. This is fine for non-threaded + # plugins because they usually won't answer anything after that; + # but not for threaded plugins. + # TODO: also detect threaded commands + for cb in self.irc.callbacks: + if cb.threaded: + timeout = self.timeout + break m = self._feedMsg(query, timeout=timeout, **kwargs) self.assertFalse(m, 'Unexpected response: %r' % m) return m - def assertSnarfNoResponse(self, query, timeout=0, **kwargs): + def assertSnarfNoResponse(self, query, timeout=None, **kwargs): return self.assertNoResponse(query, timeout=timeout, usePrefixChar=False, **kwargs)