def test_1110(self): """output(): Raises CLIError on invalid path""" msg_str = 'line1\nline2\n' with pytest.raises(d1_cli.impl.cli_exceptions.CLIError): cli_util.output( StringIO.StringIO(msg_str), path='/some/invalid/path', )
def test_1100(self): """output(): Output to file when file path is provided""" msg_str = 'line1\nline2\n' with d1_test.d1_test_case.capture_std() as (out_stream, err_stream): with tempfile.NamedTemporaryFile() as tmp_file: tmp_file_path = tmp_file.name cli_util.output(StringIO.StringIO(msg_str), path=tmp_file_path) assert '' == out_stream.getvalue() with open(tmp_file_path, 'r') as tmp_file: assert msg_str == tmp_file.read()
def test_1090(self): """output(): Output to screen when no file path is provided""" msg_str = 'line1\nline2\n' with d1_test.d1_test_case.capture_std() as (out_stream, err_stream): cli_util.output(StringIO.StringIO(msg_str), path=None) assert msg_str == out_stream.getvalue()