[Zope-CVS] CVS: Packages/SpreadLog/tests - __init__.py:1.1 testSpreadLog.py:1.1
Jeremy Hylton
jeremy@zope.com
Mon, 8 Oct 2001 21:51:57 -0400
Update of /cvs-repository/Packages/SpreadLog/tests
In directory cvs.zope.org:/tmp/cvs-serv22424
Added Files:
__init__.py testSpreadLog.py
Log Message:
Simple tests based on zLOG tests
=== Added File Packages/SpreadLog/tests/__init__.py ===
=== Added File Packages/SpreadLog/tests/testSpreadLog.py ===
import os
import tempfile
import threading
import unittest
import zLOG
from zLOG.tests.testzLog import StupidLogTest
import SpreadLog
from SpreadLog import server
class SpreadLogTest(StupidLogTest):
__super_setUp = StupidLogTest.setUp
# XXX There's got to be a better way to connect to spread.
spread_name = "4803@localhost"
def setUp(self):
self.__super_setUp()
self._log = open(self.path, 'a', 1)
self.exit = server.TestExitHook()
lock = threading.Lock()
lock.acquire()
t = threading.Thread(target=server.main,
args=(self.spread_name,
self._log),
kwargs={'test_exit': self.exit,
'ready_lock': lock})
self.thread = t
t.start()
lock.acquire()
def getLogFile(self):
self.exit.set()
self.thread.join()
self._log.close()
return open(self.path, 'rb')
def setLog(self, severity=0):
os.environ['SPREAD_LOG_NAME'] = self.spread_name
SpreadLog.log.initialize()
def test_suite():
return unittest.makeSuite(SpreadLogTest, 'check')
if __name__ == "__main__":
del StupidLogTest
loader = unittest.TestLoader()
loader.testMethodPrefix = "check"
unittest.main(testLoader=loader)