| Revision 330,
980 bytes
checked in by xi, 4 years ago
(diff) |
|
Share data files between Py2 and Py3 test suites.
|
| Rev | Line | |
|---|
| [39] | 1 | |
|---|
| [322] | 2 | import yaml |
|---|
| [39] | 3 | |
|---|
| [322] | 4 | def test_marks(marks_filename, verbose=False): |
|---|
| 5 | inputs = open(marks_filename, 'rb').read().split('---\n')[1:] |
|---|
| 6 | for input in inputs: |
|---|
| 7 | index = 0 |
|---|
| 8 | line = 0 |
|---|
| 9 | column = 0 |
|---|
| 10 | while input[index] != '*': |
|---|
| 11 | if input[index] == '\n': |
|---|
| 12 | line += 1 |
|---|
| 13 | column = 0 |
|---|
| 14 | else: |
|---|
| 15 | column += 1 |
|---|
| 16 | index += 1 |
|---|
| 17 | mark = yaml.Mark(marks_filename, index, line, column, unicode(input), index) |
|---|
| 18 | snippet = mark.get_snippet(indent=2, max_length=79) |
|---|
| 19 | if verbose: |
|---|
| 20 | print snippet |
|---|
| 21 | assert isinstance(snippet, str), type(snippet) |
|---|
| 22 | assert snippet.count('\n') == 1, snippet.count('\n') |
|---|
| 23 | data, pointer = snippet.split('\n') |
|---|
| 24 | assert len(data) < 82, len(data) |
|---|
| 25 | assert data[len(pointer)-1] == '*', data[len(pointer)-1] |
|---|
| [39] | 26 | |
|---|
| [322] | 27 | test_marks.unittest = ['.marks'] |
|---|
| [39] | 28 | |
|---|
| [322] | 29 | if __name__ == '__main__': |
|---|
| 30 | import test_appliance |
|---|
| 31 | test_appliance.run(globals()) |
|---|
| [39] | 32 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.