Commit 964a0175 authored by Jeremy Hylton's avatar Jeremy Hylton

In verifyEntry(), check for end-of-file before anything is found.

Add getLogFile() method that provides hook for SpreadLog subclass.
parent d96afcc0
...@@ -48,6 +48,8 @@ class StupidLogTest(unittest.TestCase): ...@@ -48,6 +48,8 @@ class StupidLogTest(unittest.TestCase):
# skip to the beginning of next entry # skip to the beginning of next entry
line = f.readline() line = f.readline()
while line != "------\n": while line != "------\n":
if not line:
self.fail("can't find entry in log file")
line = f.readline() line = f.readline()
line = f.readline().strip() line = f.readline().strip()
...@@ -80,18 +82,21 @@ class StupidLogTest(unittest.TestCase): ...@@ -80,18 +82,21 @@ class StupidLogTest(unittest.TestCase):
if line == last: if line == last:
break break
def getLogFile(self):
return open(self.path, 'rb')
def checkBasics(self): def checkBasics(self):
self.setLog() self.setLog()
zLOG.LOG("basic", zLOG.INFO, "summary") zLOG.LOG("basic", zLOG.INFO, "summary")
f = open(self.path, 'rb') f = self.getLogFile()
self.verifyEntry(f, subsys="basic", summary="summary") self.verifyEntry(f, subsys="basic", summary="summary")
def checkDetail(self): def checkDetail(self):
self.setLog() self.setLog()
zLOG.LOG("basic", zLOG.INFO, "xxx", "this is a detail") zLOG.LOG("basic", zLOG.INFO, "xxx", "this is a detail")
f = open(self.path, 'rb') f = self.getLogFile()
self.verifyEntry(f, subsys="basic", detail="detail") self.verifyEntry(f, subsys="basic", detail="detail")
def checkError(self): def checkError(self):
...@@ -104,7 +109,7 @@ class StupidLogTest(unittest.TestCase): ...@@ -104,7 +109,7 @@ class StupidLogTest(unittest.TestCase):
zLOG.LOG("basic", zLOG.INFO, "summary") zLOG.LOG("basic", zLOG.INFO, "summary")
zLOG.LOG("basic", zLOG.ERROR, "raised exception", error=err) zLOG.LOG("basic", zLOG.ERROR, "raised exception", error=err)
f = open(self.path, 'rb') f = self.getLogFile()
self.verifyEntry(f, subsys="basic", summary="summary") self.verifyEntry(f, subsys="basic", summary="summary")
self.verifyEntry(f, subsys="basic", severity=zLOG.ERROR, self.verifyEntry(f, subsys="basic", severity=zLOG.ERROR,
error=err) error=err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment