1a5f9918aSopenharmony_ci 2a5f9918aSopenharmony_ciimport yaml 3a5f9918aSopenharmony_ci 4a5f9918aSopenharmony_cidef test_marks(marks_filename, verbose=False): 5a5f9918aSopenharmony_ci with open(marks_filename, 'r') as file: 6a5f9918aSopenharmony_ci inputs = file.read().split('---\n')[1:] 7a5f9918aSopenharmony_ci for input in inputs: 8a5f9918aSopenharmony_ci index = 0 9a5f9918aSopenharmony_ci line = 0 10a5f9918aSopenharmony_ci column = 0 11a5f9918aSopenharmony_ci while input[index] != '*': 12a5f9918aSopenharmony_ci if input[index] == '\n': 13a5f9918aSopenharmony_ci line += 1 14a5f9918aSopenharmony_ci column = 0 15a5f9918aSopenharmony_ci else: 16a5f9918aSopenharmony_ci column += 1 17a5f9918aSopenharmony_ci index += 1 18a5f9918aSopenharmony_ci mark = yaml.Mark(marks_filename, index, line, column, input, index) 19a5f9918aSopenharmony_ci snippet = mark.get_snippet(indent=2, max_length=79) 20a5f9918aSopenharmony_ci if verbose: 21a5f9918aSopenharmony_ci print(snippet) 22a5f9918aSopenharmony_ci assert isinstance(snippet, str), type(snippet) 23a5f9918aSopenharmony_ci assert snippet.count('\n') == 1, snippet.count('\n') 24a5f9918aSopenharmony_ci data, pointer = snippet.split('\n') 25a5f9918aSopenharmony_ci assert len(data) < 82, len(data) 26a5f9918aSopenharmony_ci assert data[len(pointer)-1] == '*', data[len(pointer)-1] 27a5f9918aSopenharmony_ci 28a5f9918aSopenharmony_citest_marks.unittest = ['.marks'] 29a5f9918aSopenharmony_ci 30a5f9918aSopenharmony_ciif __name__ == '__main__': 31a5f9918aSopenharmony_ci import test_appliance 32a5f9918aSopenharmony_ci test_appliance.run(globals()) 33a5f9918aSopenharmony_ci 34