mirror of
https://github.com/Mikaela/Limnoria.git
synced 2025-01-31 06:34:32 +01:00
Has more useful failure messages and does proper tearDown of the irc object now.
This commit is contained in:
parent
8e068ce8c0
commit
270982d422
21
test/test.py
21
test/test.py
@ -34,14 +34,25 @@ sys.path.insert(0, 'src')
|
|||||||
sys.path.insert(0, 'test')
|
sys.path.insert(0, 'test')
|
||||||
sys.path.insert(0, 'plugins')
|
sys.path.insert(0, 'plugins')
|
||||||
|
|
||||||
|
|
||||||
|
import conf
|
||||||
|
conf.dataDir = 'test-data'
|
||||||
|
|
||||||
from fix import *
|
from fix import *
|
||||||
|
|
||||||
|
import gc
|
||||||
import re
|
import re
|
||||||
import glob
|
import glob
|
||||||
import time
|
import time
|
||||||
import os.path
|
import os.path
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
if not os.path.exists(conf.dataDir):
|
||||||
|
os.mkdir(conf.dataDir)
|
||||||
|
|
||||||
|
for filename in os.listdir(conf.dataDir):
|
||||||
|
os.remove(os.path.join(conf.dataDir, filename))
|
||||||
|
|
||||||
import world
|
import world
|
||||||
import irclib
|
import irclib
|
||||||
import ircmsgs
|
import ircmsgs
|
||||||
@ -100,6 +111,10 @@ class PluginTestCase(unittest.TestCase):
|
|||||||
plugin = module.Class()
|
plugin = module.Class()
|
||||||
self.irc.addCallback(plugin)
|
self.irc.addCallback(plugin)
|
||||||
|
|
||||||
|
def tearDown(self):
|
||||||
|
self.irc.die()
|
||||||
|
gc.collect()
|
||||||
|
|
||||||
def _feedMsg(self, query):
|
def _feedMsg(self, query):
|
||||||
self.irc.feedMsg(ircmsgs.privmsg(self.nick, query, prefix=self.prefix))
|
self.irc.feedMsg(ircmsgs.privmsg(self.nick, query, prefix=self.prefix))
|
||||||
fed = time.time()
|
fed = time.time()
|
||||||
@ -119,12 +134,14 @@ class PluginTestCase(unittest.TestCase):
|
|||||||
def assertError(self, query):
|
def assertError(self, query):
|
||||||
m = self._feedMsg(query)
|
m = self._feedMsg(query)
|
||||||
self.failUnless(m)
|
self.failUnless(m)
|
||||||
self.failUnless(m.args[1].startswith('Error:'), '%r errored' % query)
|
self.failUnless(m.args[1].startswith('Error:'),
|
||||||
|
'%r did not error: %s' % (query, m.args[1]))
|
||||||
|
|
||||||
def assertNotError(self, query):
|
def assertNotError(self, query):
|
||||||
m = self._feedMsg(query)
|
m = self._feedMsg(query)
|
||||||
self.failUnless(m)
|
self.failUnless(m)
|
||||||
self.failIf(m.args[1].startswith('Error:'), '%r errored' % query)
|
self.failIf(m.args[1].startswith('Error:'),
|
||||||
|
'%r errored: %s' % (query, m.args[1]))
|
||||||
|
|
||||||
def assertResponse(self, query, expectedResponse):
|
def assertResponse(self, query, expectedResponse):
|
||||||
m = self._feedMsg(query)
|
m = self._feedMsg(query)
|
||||||
|
Loading…
Reference in New Issue
Block a user