def setup_method(self, method): self.app = app.test_client()
def setUp(self): self.app = app.test_client()
import json import logging from unittest import mock from werkzeug import Headers from freezegun import freeze_time from title_ui.custom_extensions.enhanced_logging.main import EnhancedLogging from title_ui.main import app logger = logging.getLogger('title-ui') 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: # 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"