def test_get_yaml_multidoc_data_filenotfound_error( self, capsys, quiet_logger, force_ruamel_load_keyboardinterrupt): yp = get_yaml_editor() docs_yielded = 0 for doc in get_yaml_multidoc_data(yp, quiet_logger, "no-such.file"): if not doc and not isinstance(doc, bool): docs_yielded += 1 assert docs_yielded == 0 captured = capsys.readouterr() assert -1 < captured.err.find("File not found")
def test_get_yaml_multidoc_data_composition_error(self, capsys, quiet_logger, badcmp_yaml_file): yp = get_yaml_editor() docs_yielded = 0 for doc in get_yaml_multidoc_data(yp, quiet_logger, badcmp_yaml_file): if not doc and not isinstance(doc, bool): docs_yielded += 1 assert docs_yielded == 0 captured = capsys.readouterr() assert -1 < captured.err.find("YAML composition error")
def test_get_yaml_multidoc_data_syntax_error(self, capsys, quiet_logger, tmp_path_factory, badsyntax_yaml_file): yp = get_yaml_editor() docs_yielded = 0 for doc in get_yaml_multidoc_data(yp, quiet_logger, badsyntax_yaml_file): if not doc and not isinstance(doc, bool): docs_yielded += 1 assert docs_yielded == 0 captured = capsys.readouterr() assert -1 < captured.err.find("YAML syntax error")
def test_get_yaml_multidoc_data_keyboardinterrupt_error( self, capsys, quiet_logger, tmp_path_factory, force_ruamel_load_keyboardinterrupt): yp = get_yaml_editor() content = """--- no: '' """ yaml_file = create_temp_yaml_file(tmp_path_factory, content) docs_yielded = 0 for doc in get_yaml_multidoc_data(yp, quiet_logger, yaml_file): if not doc and not isinstance(doc, bool): docs_yielded += 1 assert docs_yielded == 0 captured = capsys.readouterr() assert -1 < captured.err.find("keyboard interrupt")
def test_get_yaml_multidoc_data_duplicateanchor_error( self, capsys, quiet_logger, tmp_path_factory): yp = get_yaml_editor() content = """--- aliases: - &anchor value1 - &anchor value2 """ yaml_file = create_temp_yaml_file(tmp_path_factory, content) docs_yielded = 0 for doc in get_yaml_multidoc_data(yp, quiet_logger, yaml_file): if not doc and not isinstance(doc, bool): docs_yielded += 1 assert docs_yielded == 0 captured = capsys.readouterr() assert -1 < captured.err.find("Duplicate YAML Anchor detected")
def test_get_yaml_multidoc_data_construction_error(self, capsys, quiet_logger, tmp_path_factory): yp = get_yaml_editor() content = """--- missing: <<: """ yaml_file = create_temp_yaml_file(tmp_path_factory, content) docs_yielded = 0 for doc in get_yaml_multidoc_data(yp, quiet_logger, yaml_file): if not doc and not isinstance(doc, bool): docs_yielded += 1 assert docs_yielded == 0 captured = capsys.readouterr() assert -1 < captured.err.find("YAML construction error")