def setup_method(self, method):
     self.app = app.test_client()
示例#2
0
from unittest import mock
import logging
import json
from freezegun import freeze_time
from hmlr_design_system.main import app
from hmlr_design_system.custom_extensions.enhanced_logging.main import EnhancedLogging
from werkzeug import Headers

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


def parse_log_output(capmanager):
    # Suppress stdout/stderr and capture the contents
    out, err = capmanager.suspend_global_capture(in_=True)
    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:"
            "\n\n-------\n{}------\n\n"
            "Captured stderr was:"
            "\n-------\n{}-------".format(out, err))
示例#3
0
 def setUp(self):
     self.app = app.test_client()
示例#4
0
    def setup_method(self, method):
        self.app = app.test_client()
        app.jinja_env.lstrip_blocks = True
        app.jinja_env.trim_blocks = True

        app.config['WTF_CSRF_ENABLED'] = False