def test_no_output_when_error_display_false(self): with patch('sys.stdout', new=io.BytesIO()) as fake_out: jo = JsonOutput() jo.warn("""Things have not gone according to plan. Please exit the building in an orderly fashion.""") val = fake_out.getvalue() assert val == b""
def _output(self, opts): if opts['output'] == 'json' or 'url_file' in opts: output = JsonOutput(error_log=opts['error_log']) else: output = StandardOutput(error_log=opts['error_log']) if opts['debug']: output.debug_output = True return output
def test_log_output_when_error_display_false(self): warn_string = 'warn_string' error_file = '/tmp/a' with patch('sys.stdout', new=io.StringIO()) as fake_out: jo = JsonOutput(error_log=error_file) jo.error_log = io.StringIO() jo.warn(warn_string) file_output = jo.error_log.getvalue() standard_out = fake_out.getvalue() assert standard_out == "" assert warn_string in file_output
def test_output_defaults(self): jo = JsonOutput() so = StandardOutput() assert jo.errors_display == False assert so.errors_display == True