Merge pull request #587 from Unrud/testscapturelogging

Capture log messages during tests
This commit is contained in:
Unrud 2017-05-30 07:55:05 +02:00 committed by GitHub
commit bc49542a62
2 changed files with 10 additions and 2 deletions

View File

@ -19,15 +19,25 @@ Tests for Radicale.
""" """
import logging
import os import os
import sys import sys
from io import BytesIO from io import BytesIO
sys.path.insert(0, os.path.dirname(os.path.dirname(__file__))) sys.path.insert(0, os.path.dirname(os.path.dirname(__file__)))
logger = logging.getLogger("radicale_test")
if not logger.hasHandlers():
handler = logging.StreamHandler(sys.stderr)
handler.setFormatter(logging.Formatter("%(levelname)s: %(message)s"))
logger.addHandler(handler)
logger.setLevel(logging.DEBUG)
class BaseTest: class BaseTest:
"""Base class for tests.""" """Base class for tests."""
logger = logger
def request(self, method, path, data=None, **args): def request(self, method, path, data=None, **args):
"""Send a request.""" """Send a request."""
self.application._status = None self.application._status = None

View File

@ -20,7 +20,6 @@ Radicale tests with simple requests.
""" """
import base64 import base64
import logging
import os import os
import posixpath import posixpath
import shutil import shutil
@ -868,7 +867,6 @@ class BaseFileSystemTest(BaseTest):
def setup(self): def setup(self):
self.configuration = config.load() self.configuration = config.load()
self.configuration.set("storage", "type", self.storage_type) self.configuration.set("storage", "type", self.storage_type)
self.logger = logging.getLogger("radicale_test")
self.colpath = tempfile.mkdtemp() self.colpath = tempfile.mkdtemp()
self.configuration.set("storage", "filesystem_folder", self.colpath) self.configuration.set("storage", "filesystem_folder", self.colpath)
# Disable syncing to disk for better performance # Disable syncing to disk for better performance