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