summaryrefslogtreecommitdiff
path: root/cherrypy/test/logtest.py
diff options
context:
space:
mode:
authorGustavo Picon <tabo@tabo.pe>2014-01-12 13:57:44 -0500
committerGustavo Picon <tabo@tabo.pe>2014-01-12 13:57:44 -0500
commitc26eb490862e664dc4ef4ea6e55c1dbd106146c4 (patch)
treef997c23aa6d04fc7db78e66ad5f58429b3be824e /cherrypy/test/logtest.py
parentfb84f7713d6ced0031dacb0e7e59d516cc681a4d (diff)
downloadcherrypy-git-c26eb490862e664dc4ef4ea6e55c1dbd106146c4.tar.gz
Running: autopep8 -vvvvv -i `find . -name '*.py'`
--HG-- branch : autopep8
Diffstat (limited to 'cherrypy/test/logtest.py')
-rw-r--r--cherrypy/test/logtest.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/cherrypy/test/logtest.py b/cherrypy/test/logtest.py
index cbc0c330..3482c9ec 100644
--- a/cherrypy/test/logtest.py
+++ b/cherrypy/test/logtest.py
@@ -10,11 +10,14 @@ from cherrypy._cpcompat import basestring, ntob, unicodestr
try:
# On Windows, msvcrt.getch reads a single char without output.
import msvcrt
+
def getchar():
return msvcrt.getch()
except ImportError:
# Unix getchr
- import tty, termios
+ import tty
+ import termios
+
def getchar():
fd = sys.stdin.fileno()
old_settings = termios.tcgetattr(fd)
@@ -27,6 +30,7 @@ except ImportError:
class LogCase(object):
+
"""unittest.TestCase mixin for testing log messages.
logfile: a filename for the desired log. Yes, I know modes are evil,
@@ -96,7 +100,8 @@ class LogCase(object):
key = str(time.time())
self.lastmarker = key
- open(self.logfile, 'ab+').write(ntob("%s%s\n" % (self.markerPrefix, key),"utf-8"))
+ open(self.logfile, 'ab+').write(ntob("%s%s\n" %
+ (self.markerPrefix, key), "utf-8"))
def _read_marked_region(self, marker=None):
"""Return lines from self.logfile in the marked region.
@@ -104,8 +109,8 @@ class LogCase(object):
If marker is None, self.lastmarker is used. If the log hasn't
been marked (using self.markLog), the entire log will be returned.
"""
-## # Give the logger time to finish writing?
-## time.sleep(0.5)
+# Give the logger time to finish writing?
+# time.sleep(0.5)
logfile = self.logfile
marker = marker or self.lastmarker
@@ -169,7 +174,8 @@ class LogCase(object):
lines = lines.encode('utf-8')
if lines not in data[sliceargs]:
msg = "%r not found on log line %r" % (lines, sliceargs)
- self._handleLogError(msg, [data[sliceargs],"--EXTRA CONTEXT--"] + data[sliceargs+1:sliceargs+6], marker, lines)
+ self._handleLogError(
+ msg, [data[sliceargs], "--EXTRA CONTEXT--"] + data[sliceargs + 1:sliceargs + 6], marker, lines)
else:
# Multiple args. Use __getslice__ and require lines to be list.
if isinstance(lines, tuple):
@@ -185,4 +191,3 @@ class LogCase(object):
if line not in logline:
msg = "%r not found in log" % line
self._handleLogError(msg, data[start:stop], marker, line)
-