Exemplo n.º 1
0
import json
import logging
from unittest import mock

from werkzeug.datastructures import Headers

from demo.custom_extensions.enhanced_logging.main import EnhancedLogging
from demo.main import app
from freezegun import freeze_time

logger = logging.getLogger("hmlr-design-system")
client = app.test_client()


def parse_log_output(capmanager):
    # Suppress stdout/stderr and capture the contents
    capmanager.suspend_global_capture()
    out, err = capmanager.read_global_capture()
    capmanager.resume_global_capture()

    # Try and parse it as json
    try:
        return json.loads(out)
    except ValueError as e:
        # If we can't parse it, print a useful err to allow people to debug it.
        # The default ValueError is particularly unhelpful in actually diagnosing the problem
        # Re-print the stdout and stderr because capturing it above suppresses it
        print(out)
        print(err)
        raise Exception(
            "Error parsing log output as JSON.\nCaptured stdout was:"
 def setup_method(self, method):
     self.app = app.test_client()
Exemplo n.º 3
0
 def setUp(self):
     self.app = app.test_client()