示例#1
0
def test_variable_ends_text():
    assert tokenize('great is {foo}') == [{
        'type': TEXT_TOKEN,
        'value': 'great is '
    }, {
        'type': NAME_TOKEN,
        'value': 'foo'
    }]
示例#2
0
def test_open_but_no_close_after_variable():
    assert tokenize('{bar} after {foo') == [{
        'type': NAME_TOKEN,
        'value': 'bar'
    }, {
        'type': TEXT_TOKEN,
        'value': ' after {foo'
    }]
示例#3
0
def test_two_variables_follow():
    assert tokenize('{foo}{bar}') == [{
        'type': NAME_TOKEN,
        'value': 'foo'
    }, {
        'type': NAME_TOKEN,
        'value': 'bar'
    }]
示例#4
0
def test_variable_starts_text():
    assert tokenize('{foo} is great') == [{
        'type': NAME_TOKEN,
        'value': 'foo'
    }, {
        'type': TEXT_TOKEN,
        'value': ' is great'
    }]
示例#5
0
def test_whitespace_after_open_with_variable():
    assert tokenize('{ foo}{bar}') == [{
        'type': TEXT_TOKEN,
        'value': '{ foo}'
    }, {
        'type': NAME_TOKEN,
        'value': 'bar'
    }]
示例#6
0
def test_tokenize_variable_in_text():
    assert tokenize('the {foo} is great') == [{
        'type': TEXT_TOKEN,
        'value': 'the '
    }, {
        'type': NAME_TOKEN,
        'value': 'foo'
    }, {
        'type': TEXT_TOKEN,
        'value': ' is great'
    }]
示例#7
0
def test_two_variables_with_text():
    assert tokenize('a{foo}b{bar}c') == [{
        'type': TEXT_TOKEN,
        'value': 'a'
    }, {
        'type': NAME_TOKEN,
        'value': 'foo'
    }, {
        'type': TEXT_TOKEN,
        'value': 'b'
    }, {
        'type': NAME_TOKEN,
        'value': 'bar'
    }, {
        'type': TEXT_TOKEN,
        'value': 'c'
    }]
示例#8
0
def test_just_close():
    assert tokenize('foo } bar') == [{
        'type': TEXT_TOKEN,
        'value': 'foo } bar'
    }]
示例#9
0
def test_open_but_no_close_after_text():
    assert tokenize('after {foo') == [{
        'type': TEXT_TOKEN,
        'value': 'after {foo'
    }]
示例#10
0
def test_open_but_no_close():
    assert tokenize('{foo') == [{'type': TEXT_TOKEN, 'value': '{foo'}]
示例#11
0
def test_no_variables():
    assert tokenize('Hello world!') == [{
        'type': TEXT_TOKEN,
        'value': 'Hello world!'
    }]
示例#12
0
def test_tokenize_single_variable():
    assert tokenize("{foo}") == [{'type': NAME_TOKEN, 'value': 'foo'}]
示例#13
0
def test_whitespace_after_open():
    assert tokenize('{ foo}') == [{'type': TEXT_TOKEN, 'value': '{ foo}'}]
示例#14
0
def test_non_stripped_variable():
    assert tokenize('{foo }') == [{'type': NAME_TOKEN, 'value': 'foo'}]
示例#15
0
def test_whitespace_variable():
    assert tokenize('{ }') == [{'type': TEXT_TOKEN, 'value': '{ }'}]
示例#16
0
def test_empty_variable():
    assert tokenize('{}') == [{'type': TEXT_TOKEN, 'value': '{}'}]