Package cherrypy :: Package test :: Module logtest :: Class LogCase
[hide private]
[frames] | no frames]

Class LogCase

source code

object --+
         |
        LogCase
Known Subclasses:

unittest.TestCase mixin for testing log messages.

logfile: a filename for the desired log. Yes, I know modes are evil,
    but it makes the test functions so much cleaner to set this once.

lastmarker: the last marker in the log. This can be used to search for
    messages since the last marker.

markerPrefix: a string with which to prefix log markers. This should be
    unique enough from normal log output to use for marker identification.

Instance Methods [hide private]
 
_handleLogError(self, msg, data, marker, pattern) source code
 
exit(self) source code
 
emptyLog(self)
Overwrite self.logfile with 0 bytes.
source code
 
markLog(self, key=None)
Insert a marker line into the log and set self.lastmarker.
source code
 
_read_marked_region(self, marker=None)
Return lines from self.logfile in the marked region.
source code
 
assertInLog(self, line, marker=None)
Fail if the given (partial) line is not in the log.
source code
 
assertNotInLog(self, line, marker=None)
Fail if the given (partial) line is in the log.
source code
 
assertLog(self, sliceargs, lines, marker=None)
Fail if log.readlines()[sliceargs] is not contained in 'lines'.
source code

Inherited from object: __delattr__, __getattribute__, __hash__, __init__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __str__

Class Variables [hide private]
  logfile = None
  lastmarker = None
  markerPrefix = 'test suite marker: '
Properties [hide private]

Inherited from object: __class__

Method Details [hide private]

_read_marked_region(self, marker=None)

source code 

Return lines from self.logfile in the marked region.

If marker is None, self.lastmarker is used. If the log hasn't been marked (using self.markLog), the entire log will be returned.

assertInLog(self, line, marker=None)

source code 

Fail if the given (partial) line is not in the log.

The log will be searched from the given marker to the next marker. If marker is None, self.lastmarker is used. If the log hasn't been marked (using self.markLog), the entire log will be searched.

assertNotInLog(self, line, marker=None)

source code 

Fail if the given (partial) line is in the log.

The log will be searched from the given marker to the next marker. If marker is None, self.lastmarker is used. If the log hasn't been marked (using self.markLog), the entire log will be searched.

assertLog(self, sliceargs, lines, marker=None)

source code 

Fail if log.readlines()[sliceargs] is not contained in 'lines'.

The log will be searched from the given marker to the next marker. If marker is None, self.lastmarker is used. If the log hasn't been marked (using self.markLog), the entire log will be searched.