| Revision 121,
1.1 KB
checked in by xi, 7 years ago
(diff) |
|
Add a branch for working on Emitter.
|
| Rev | Line | |
|---|
| [39] | 1 | |
|---|
| 2 | import test_appliance |
|---|
| 3 | |
|---|
| [116] | 4 | from yaml.reader import Mark |
|---|
| [39] | 5 | |
|---|
| [116] | 6 | class TestMark(test_appliance.TestAppliance): |
|---|
| [39] | 7 | |
|---|
| [116] | 8 | def _testMarks(self, test_name, marks_filename): |
|---|
| 9 | inputs = file(marks_filename, 'rb').read().split('---\n')[1:] |
|---|
| [39] | 10 | for input in inputs: |
|---|
| 11 | index = 0 |
|---|
| 12 | line = 0 |
|---|
| 13 | column = 0 |
|---|
| 14 | while input[index] != '*': |
|---|
| 15 | if input[index] == '\n': |
|---|
| 16 | line += 1 |
|---|
| 17 | column = 0 |
|---|
| 18 | else: |
|---|
| 19 | column += 1 |
|---|
| 20 | index += 1 |
|---|
| [120] | 21 | mark = Mark(test_name, index, line, column, unicode(input), index) |
|---|
| [116] | 22 | snippet = mark.get_snippet(indent=2, max_length=79) |
|---|
| [45] | 23 | #print "INPUT:" |
|---|
| 24 | #print input |
|---|
| 25 | #print "SNIPPET:" |
|---|
| 26 | #print snippet |
|---|
| 27 | self.failUnless(isinstance(snippet, str)) |
|---|
| [47] | 28 | self.failUnlessEqual(snippet.count('\n'), 1) |
|---|
| 29 | data, pointer = snippet.split('\n') |
|---|
| 30 | self.failUnless(len(data) < 82) |
|---|
| [45] | 31 | self.failUnlessEqual(data[len(pointer)-1], '*') |
|---|
| [39] | 32 | |
|---|
| [116] | 33 | TestMark.add_tests('testMarks', '.marks') |
|---|
| [39] | 34 | |
|---|
Note: See
TracBrowser
for help on using the repository browser.