cherrypy.test.logtest module¶
Logtest, a unittest.TestCase helper for testing log output.
- class cherrypy.test.logtest.LogCase[source]¶
Bases:
object
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.
- _read_marked_region(marker=None)[source]¶
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(line, marker=None)[source]¶
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.
- assertLog(sliceargs, lines, marker=None)[source]¶
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.
- assertNotInLog(line, marker=None)[source]¶
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.
- assertValidUUIDv4(marker=None)[source]¶
Fail if the given UUIDv4 is not valid.
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.
- interactive = False¶
- lastmarker = None¶
- logfile = None¶
- markerPrefix = b'test suite marker: '¶