Debian Codegraph @

test/utils.py

raw symbols SCIP
1 import re
2
3
4 def lget(src_list, index):
5 try:
6 return src_list[index]
7 except IndexError:
8 return ""
9
10
11 def read_fixture_file(path):
12 tests = []
13 skip_next = False
14 comment_re = re.compile(r"^%.*")
15
16 with open(path, encoding="utf-8") as f:
17 lines = [x.rstrip() for x in f.readlines()]
18
19 for idx, line in enumerate(lines):
20 if skip_next:
21 skip_next = False
22 continue
23
24 line = comment_re.sub("", line)
25
26 next_line = comment_re.sub("", lget(lines, idx + 1))
27
28 if not line.strip():
29 continue
30
31 if next_line.strip():
32 tests.append([idx + 1, line, next_line])
33 skip_next = True
34 else:
35 tests.append([idx + 1, line, line])
36
37 return tests