def test_start_inner_line_match(): target = 'classBackgroundLayer(' should_match = 'class BackgroundLayer(cocos.layer.Layer)' filling = '\n'.join(['this is a line', 'this is another']) text = 'A fine first line.\n' + should_match + '\n' + filling lines = text.split('\n') it = enumerate(lines) start_line = get_start_line(it, target) assert start_line == 1 assert it.next() == (2, lines[2])
def test_start_1st_line_match(): target = 'classBackgroundLayer(' should_match = 'class BackgroundLayer(cocos.layer.Layer)' filling = '\n'.join(['this is a line', 'this is another']) text = should_match + '\n' + filling lines = text.split('\n') it = enumerate(lines) start_line = get_start_line(it, target) assert start_line == 0 assert six.next(it) == (1, lines[1])
def test_start_inner_line_match(): target = 'classBackgroundLayer(' should_match = 'class BackgroundLayer(cocos.layer.Layer)' filling = '\n'.join([ 'this is a line', 'this is another' ]) text = 'A fine first line.\n' + should_match + '\n' + filling lines = text.split('\n') it = enumerate(lines) start_line = get_start_line(it, target) assert start_line == 1 assert it.next() == (2, lines[2])
def test_start_1st_line_match(): target = 'classBackgroundLayer(' should_match = 'class BackgroundLayer(cocos.layer.Layer)' filling = '\n'.join([ 'this is a line', 'this is another' ]) text = should_match + '\n' + filling lines = text.split('\n') it = enumerate(lines) start_line = get_start_line(it, target) assert start_line == 0 assert six.next(it) == (1, lines[1])
def test_start_no_match(): target = 'classBackgroundLayer(' filling = '\n'.join(['this is a line', 'this is another']) text = filling lines = text.split('\n') it = enumerate(lines) start_line = get_start_line(it, target) assert start_line is None # here next should raise StoptIteration StopIteration_raised = False try: it.next() except StopIteration: StopIteration_raised = True assert StopIteration_raised
def test_start_no_match(): target = 'classBackgroundLayer(' filling = '\n'.join([ 'this is a line', 'this is another' ]) text = filling lines = text.split('\n') it = enumerate(lines) start_line = get_start_line(it, target) assert start_line is None # here next should raise StoptIteration StopIteration_raised = False try: it.next() except StopIteration: StopIteration_raised = True assert StopIteration_raised