Working on the scanner.
[pyyaml/python3.git] / tests / test_marker.py
blob4570098afdbc7fe2b35dfaca515c384ba058bef0
2 import test_appliance
4 from yaml.marker import Marker
6 class TestMarker(test_appliance.TestAppliance):
8 def _testMarkers(self, test_name, markers_filename):
9 inputs = file(markers_filename, 'rb').read().split('---\n')[1:]
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
21 for str_type in [str, unicode]:
22 marker = Marker(test_name, str_type(input), index, line, column)
23 snippet = marker.get_snippet()
24 #print "INPUT:"
25 #print input
26 #print "SNIPPET:"
27 #print snippet
28 self.failUnless(isinstance(snippet, str))
29 self.failUnlessEqual(snippet.count('\n'), 2)
30 data, pointer, dummy = snippet.split('\n')
31 self.failUnless(len(data) < 80)
32 self.failUnlessEqual(data[len(pointer)-1], '*')
34 TestMarker.add_tests('testMarkers', '.markers')