Exemplo n.º 1
0
def test_rule_applying():
    r1 = Rule(pattern='b{2}', replacement='cc')
    r2 = Rule(pattern='c{2}', replacement='dd')

    r = Richtypo()
    r.rules = [r1, r2]
    r.text = 'abb'
    r.apply_rule_chain()

    assert r.text == 'add'
Exemplo n.º 2
0
def test_rule_order():
    """
    Check if rules are applyied in order they are supplied
    """
    r1 = Rule(pattern='b{2}', replacement='cc')
    r2 = Rule(pattern='c{2}', replacement='dd')
    r = Richtypo()
    r.rules = [r2, r1]  # r2 works only after r1
    r.text = 'abb'
    r.apply_rule_chain()

    assert r.text == 'acc'  # so the text should not be changed