Пример #1
0
def test_identity():
    """ Concatenating a diff with its inversion should be a no-op """
    string = "I'm a lumberjack, and I'm okay. I sleep all night and I work all day."
    diff = Diff([("lumberjack,", 2, False), ("parrot", 6, True), ("spam", 8, True)])
    no_diff = diff.concat(diff.invert())
    assert no_diff.apply(string) == string
Пример #2
0
def test_invert():
    """ Test that an inverted diff undoes a change """
    string = "No no no, my fish's name is Eric, Eric the fish. He's an halibut."
    diff = Diff([("no", 1, False), ("salt", 8, True)])
    altstring = diff.apply(string)
    assert diff.invert().apply(altstring) == string