Exemplo n.º 1
0
def test_objects_flatten_template_mixed(patch, tree):
    result = list(Lowering.flatten_template(tree, 'a{hello}b'))
    assert result == [
        flatten_to_string('a'),
        {'$OBJECT': 'code', 'code': 'hello'},
        flatten_to_string('b')
    ]
Exemplo n.º 2
0
def test_objects_flatten_template_escapes4(patch, tree):
    result = list(Lowering.flatten_template(tree, r'\\{\\}\\'))
    assert result == [
        flatten_to_string(r'\\'),
        {'$OBJECT': 'code', 'code': '\\'},
        flatten_to_string(r'\\')
    ]
Exemplo n.º 3
0
def test_objects_flatten_template_escapes_uni3(patch, tree):
    result = list(
        Lowering.flatten_template(tree, r"\N{LATIN CAPITAL LETTER A}")
    )
    assert result == [
        flatten_to_string(r"\N{LATIN CAPITAL LETTER A}"),
    ]
Exemplo n.º 4
0
def test_objects_flatten_template_escapes4(patch, tree):
    result = list(Lowering.flatten_template(tree, r"\\{\\}\\"))
    assert result == [
        flatten_to_string(r"\\"),
        {"$OBJECT": "code", "code": "\\"},
        flatten_to_string(r"\\"),
    ]
Exemplo n.º 5
0
def test_objects_flatten_template_mixed(patch, tree):
    result = list(Lowering.flatten_template(tree, "a{hello}b"))
    assert result == [
        flatten_to_string("a"),
        {"$OBJECT": "code", "code": "hello"},
        flatten_to_string("b"),
    ]
Exemplo n.º 6
0
def test_objects_flatten_template_escapes_uni2(patch, tree):
    result = list(Lowering.flatten_template(tree, r'\U0001F600'))
    assert result == [
        flatten_to_string(r'\U0001F600'),
    ]
Exemplo n.º 7
0
def test_objects_flatten_template_escapes_uni(patch, tree):
    result = list(Lowering.flatten_template(tree, r'\x42\t\u1212'))
    assert result == [
        flatten_to_string(r'\x42\t\u1212'),
    ]
Exemplo n.º 8
0
def test_objects_flatten_template_escapes_newlines(patch, tree):
    result = list(Lowering.flatten_template(tree, r'\n\n'))
    assert result == [
        flatten_to_string(r'\n\n'),
    ]
Exemplo n.º 9
0
def test_objects_flatten_template_escapes2(patch, tree):
    result = list(Lowering.flatten_template(tree, r'\\.\'.\".\\'))
    assert result == [
        flatten_to_string(r"""\\.'.".\\"""),
    ]
Exemplo n.º 10
0
def test_objects_flatten_template_only_templates(patch, tree):
    result = list(Lowering.flatten_template(tree, '{hello}'))
    assert result == [{'$OBJECT': 'code', 'code': 'hello'}]
Exemplo n.º 11
0
def test_objects_flatten_template_no_templates(patch, tree):
    result = list(Lowering.flatten_template(tree, '.s.'))
    assert result == [flatten_to_string('.s.')]
Exemplo n.º 12
0
def test_objects_flatten_template_escapes3(patch, tree):
    result = list(Lowering.flatten_template(tree, r"\\\\\\"))
    assert result == [
        flatten_to_string(r"\\\\\\"),
    ]
Exemplo n.º 13
0
def test_objects_flatten_template_only_templates(patch, tree):
    result = list(Lowering.flatten_template(tree, "{hello}"))
    assert result == [{"$OBJECT": "code", "code": "hello"}]