mirror of
https://github.com/Mikaela/Limnoria.git
synced 2024-11-10 12:59:22 +01:00
Moved some stuff to the __main__ part to make sure it's called only once.
This commit is contained in:
parent
2cd657c9a9
commit
fee74e9bd1
48
test/test.py
48
test/test.py
@ -48,20 +48,7 @@ import time
|
|||||||
import os.path
|
import os.path
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
if not os.path.exists(conf.dataDir):
|
|
||||||
os.mkdir(conf.dataDir)
|
|
||||||
|
|
||||||
if not os.path.exists(conf.confDir):
|
|
||||||
os.mkdir(conf.confDir)
|
|
||||||
|
|
||||||
if not os.path.exists(conf.logDir):
|
|
||||||
os.mkdir(conf.logDir)
|
|
||||||
|
|
||||||
for filename in os.listdir(conf.logDir):
|
|
||||||
os.remove(os.path.join(conf.logDir, filename))
|
|
||||||
|
|
||||||
import debug
|
import debug
|
||||||
|
|
||||||
debug.stderr = False
|
debug.stderr = False
|
||||||
|
|
||||||
import world
|
import world
|
||||||
@ -73,17 +60,6 @@ import ircutils
|
|||||||
import callbacks
|
import callbacks
|
||||||
import OwnerCommands
|
import OwnerCommands
|
||||||
|
|
||||||
fd = file(os.path.join('test', 'rfc2812.msgs'), 'r')
|
|
||||||
rawmsgs = [line.strip() for line in fd]
|
|
||||||
fd.close()
|
|
||||||
|
|
||||||
msgs = []
|
|
||||||
for s in rawmsgs:
|
|
||||||
try:
|
|
||||||
msgs.append(ircmsgs.IrcMsg(s))
|
|
||||||
except:
|
|
||||||
print 'IrcMsg constructor failed: %r' % s
|
|
||||||
|
|
||||||
nicks = ['fatjim','scn','moshez','LordVan','MetaCosm','pythong','fishfart',
|
nicks = ['fatjim','scn','moshez','LordVan','MetaCosm','pythong','fishfart',
|
||||||
'alb','d0rt','jemfinch','StyxAlso','fors','deltab','gd',
|
'alb','d0rt','jemfinch','StyxAlso','fors','deltab','gd',
|
||||||
'hellz_hunter','are_j|pub_comp','jason_','dreid','sayke_','winjer',
|
'hellz_hunter','are_j|pub_comp','jason_','dreid','sayke_','winjer',
|
||||||
@ -104,8 +80,20 @@ nicks = ['fatjim','scn','moshez','LordVan','MetaCosm','pythong','fishfart',
|
|||||||
'EliasREC','lowks__','OldSmrf','Mad77','snibril','delta','psy',
|
'EliasREC','lowks__','OldSmrf','Mad77','snibril','delta','psy',
|
||||||
'skimpIzu','Kengur','MoonFallen','kotkis','Hyperi']
|
'skimpIzu','Kengur','MoonFallen','kotkis','Hyperi']
|
||||||
|
|
||||||
|
fd = file(os.path.join('test', 'rfc2812.msgs'), 'r')
|
||||||
|
rawmsgs = [line.strip() for line in fd]
|
||||||
|
fd.close()
|
||||||
|
|
||||||
|
msgs = []
|
||||||
|
for s in rawmsgs:
|
||||||
|
try:
|
||||||
|
msgs.append(ircmsgs.IrcMsg(s))
|
||||||
|
except:
|
||||||
|
print 'IrcMsg constructor failed: %r' % s
|
||||||
|
|
||||||
nicks += [msg.nick for msg in msgs if msg.nick]
|
nicks += [msg.nick for msg in msgs if msg.nick]
|
||||||
|
|
||||||
|
|
||||||
class PluginTestCase(unittest.TestCase):
|
class PluginTestCase(unittest.TestCase):
|
||||||
"""Subclass this to write a test case for a plugin. See test_FunCommands
|
"""Subclass this to write a test case for a plugin. See test_FunCommands
|
||||||
for an example.
|
for an example.
|
||||||
@ -288,6 +276,18 @@ class PluginDocumentation:
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
if not os.path.exists(conf.dataDir):
|
||||||
|
os.mkdir(conf.dataDir)
|
||||||
|
|
||||||
|
if not os.path.exists(conf.confDir):
|
||||||
|
os.mkdir(conf.confDir)
|
||||||
|
|
||||||
|
if not os.path.exists(conf.logDir):
|
||||||
|
os.mkdir(conf.logDir)
|
||||||
|
|
||||||
|
for filename in os.listdir(conf.logDir):
|
||||||
|
os.remove(os.path.join(conf.logDir, filename))
|
||||||
|
|
||||||
world.testing = True
|
world.testing = True
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
files = sys.argv[1:]
|
files = sys.argv[1:]
|
||||||
|
Loading…
Reference in New Issue
Block a user