コード例 #1
0
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])
コード例 #2
0
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])
コード例 #3
0
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])
コード例 #4
0
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])
コード例 #5
0
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
コード例 #6
0
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