示例#1
0
def test_styled_text_push_context_attribute():
    seq = StyledSequence("", {})
    seq._enter_iteration()
    color = TM.Color("red")
    color2 = TM.Color("yellow")

    assert seq.context.color != color
    original = seq.context.color
    seq._context_push({"color": color}, {}, "sequence", 0)
    assert seq.context.color == color
    seq._context_push({"color": color2}, {}, "sequence", 0)
    assert seq.context.color == color2
    seq._context_push({}, {"color": None}, "sequence", 0)
    assert seq.context.color == color
    seq._context_push({}, {"color": None}, "sequence", 0)
    assert seq.context.color == original
示例#2
0
def test_styled_text_push_context_sequence_attribute():
    from copy import copy
    seq = StyledSequence("", {})
    seq._enter_iteration()
    tr1 = TM.Transformer(foreground="red")
    tr2 = TM.Transformer(background="yellow")

    assert tr1 not in seq.context.pretransformers
    original = copy(seq.context.pretransformers)
    seq._context_push({"pretransformer": tr1}, {}, "sequence", 0)
    assert seq.context.pretransformers[-1].foreground == tr1.foreground
    seq._context_push({"pretransformer": tr2}, {}, "sequence", 0)
    assert seq.context.pretransformers[-1].background == tr2.background
    assert seq.context.pretransformers[-2].foreground == tr1.foreground
    seq._context_push({}, {"pretransformer": None}, "sequence", 0)
    assert seq.context.pretransformers[-1].foreground == tr1.foreground
    seq._context_push({}, {"pretransformer": None}, "sequence", 0)
    assert seq.context.pretransformers == original