Moved some stuff to the __main__ part to make sure it's called only once.

This commit is contained in:
Jeremy Fincher 2003-10-05 04:42:46 +00:00
parent 2cd657c9a9
commit fee74e9bd1

View File

@ -48,20 +48,7 @@ import time
import os.path
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
debug.stderr = False
import world
@ -73,17 +60,6 @@ import ircutils
import callbacks
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',
'alb','d0rt','jemfinch','StyxAlso','fors','deltab','gd',
'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',
'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]
class PluginTestCase(unittest.TestCase):
"""Subclass this to write a test case for a plugin. See test_FunCommands
for an example.
@ -288,6 +276,18 @@ class PluginDocumentation:
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
if len(sys.argv) > 1:
files = sys.argv[1:]