示例#1
0
 def test_accept_whitespace(self):
     data_item = DataItem('x', '')
     data_items = [data_item]
     assert data_items == parse_template_parts('{x}', data_items)
     assert data_items == parse_template_parts('{x }', data_items)
     assert data_items == parse_template_parts('{ x}', data_items)
     assert data_items == parse_template_parts('{ x }', data_items)
示例#2
0
def test_variable_name_has_question_mark():
    template = '{x: x?}'
    x = DataItem('x', 1)
    parts = parse_template_parts(template, [x])
    assert parts[0].name == 'x?'
    assert parts[0].help == ''
示例#3
0
def test_variable_with_help():
    template = '{x ? what is x?}'
    x = DataItem('x', 1)
    parts = parse_template_parts(template, [x])
    assert parts[0].name == 'x'
    assert parts[0].help == 'what is x?'
示例#4
0
def test_missing_variable():
    template = '{x}'
    x, y = DataItem('x', 1), DataItem('y', 2)
    parts = parse_template_parts(template, [x, y])
    assert parts == [x, y]
示例#5
0
def test_variable_with_name():
    template = '{x : xyz}'
    x = DataItem('x', 1)
    parts = parse_template_parts(template, [x])
    assert parts[0].name == 'xyz'
示例#6
0
def test_extra_variable():
    template = '{x} {z}'
    x, y = DataItem('x', 1), DataItem('y', 2)
    parts = parse_template_parts(template, [x, y])
    assert parts == [x, '{ z }', y]
示例#7
0
def test_missing_variable_with_text():
    template = 'abc {x} xyz'
    x, y = DataItem('x', 1), DataItem('y', 2)
    parts = parse_template_parts(template, [x, y])
    assert parts == ['abc', x, 'xyz', y]
示例#8
0
 def test_recognize_names(self):
     data_item = DataItem('x', '')
     parse_template_parts('{ x : a }', [data_item])
     assert data_item.name == 'a'