source: pyyaml/trunk/tests/test_mark.py @ 322

Revision 322, 980 bytes checked in by xi, 5 years ago (diff)

Refactored the test suite; updated include and library paths in setup.cfg.

RevLine 
[39]1
[322]2import yaml
[39]3
[322]4def 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]27test_marks.unittest = ['.marks']
[39]28
[322]29if __name__ == '__main__':
30    import test_appliance
31    test_appliance.run(globals())
[39]32
Note: See TracBrowser for help on using the repository browser.