diff options
author | Andrea Spagnolo <andrea.spagnolo@scmitaly.it> | 2017-10-18 12:58:58 +0200 |
---|---|---|
committer | Sviatoslav Sydorenko <wk@sydorenko.org.ua> | 2017-10-20 13:19:38 +0300 |
commit | 122fd0506d30152a026ca0a0e56b5eda630773b3 (patch) | |
tree | 4a44600ff815424fe8085f89bc7b2765211226d4 /cherrypy/test/logtest.py | |
parent | 7d48070003cb57ff5d9fa236dbb638fa314354c3 (diff) | |
download | cherrypy-git-122fd0506d30152a026ca0a0e56b5eda630773b3.tar.gz |
Fixed test on windows
Diffstat (limited to 'cherrypy/test/logtest.py')
-rw-r--r-- | cherrypy/test/logtest.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/cherrypy/test/logtest.py b/cherrypy/test/logtest.py index 0d76a9eb..ba510f2d 100644 --- a/cherrypy/test/logtest.py +++ b/cherrypy/test/logtest.py @@ -4,6 +4,7 @@ import sys import time import six + from cherrypy._cpcompat import text_or_bytes, ntob @@ -160,6 +161,27 @@ class LogCase(object): msg = '%r found in log' % line self._handleLogError(msg, data, marker, line) + def assertValidUUIDv4(self, marker=None): + """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. + """ + data = self._read_marked_region(marker) + data = [chunk.decode('utf-8').rstrip('\n').rstrip('\r') for chunk in data] + for log_chunk in data: + try: + uuid_log = data[-1] + uuid_obj = UUID(uuid_log, version=4) + except (TypeError, ValueError): + msg = '%r not a valid UUIDv4' % uuid_log + self._handleLogError(msg, data, marker, lines) + else: + if str(uuid_obj) != uuid_log: + msg = '%r not a valid UUIDv4' % uuid_log + self._handleLogError(msg, data, marker, lines) + def assertLog(self, sliceargs, lines, marker=None): """Fail if log.readlines()[sliceargs] is not contained in 'lines'. |