Back to index

moin  1.9.0~rc2
test_diff_text.py
Go to the documentation of this file.
00001 # -*- coding: utf-8 -*-
00002 """
00003     MoinMoin - MoinMoin.util.diff_text Tests
00004 
00005     @copyright: 2007 MoinMoin:ThomasWaldmann
00006     @license: GNU GPL, see COPYING for details.
00007 """
00008 
00009 from MoinMoin.util import diff_text
00010 
00011 class TestDiffText:
00012 
00013     def testDiff(self):
00014         """ util.diff_text.diff: test correct diff calculation """
00015         in1 = """AAA 001
00016 AAA 002
00017 AAA 003
00018 AAA 004
00019 AAA 005
00020 AAA 006
00021 AAA 007
00022 AAA 008
00023 AAA 009
00024 AAA 010
00025 AAA 011
00026 AAA 012
00027 AAA 013
00028 AAA 014
00029 """
00030 
00031         in2 = """AAA 001
00032 AAA 002
00033 AAA 005
00034 AAA 006
00035 AAA 007
00036 AAA 008
00037 BBB 001
00038 BBB 002
00039 AAA 009
00040 AAA 010
00041 BBB 003
00042 """
00043 
00044         result = diff_text.diff(in1.splitlines(), in2.splitlines())
00045         result = "\n".join(result)
00046 
00047         expected = """\
00048   AAA 001
00049   AAA 002
00050 - AAA 003
00051 - AAA 004
00052   AAA 005
00053   AAA 006
00054   AAA 007
00055   AAA 008
00056 + BBB 001
00057 + BBB 002
00058   AAA 009
00059   AAA 010
00060 + BBB 003
00061 - AAA 011
00062 - AAA 012
00063 - AAA 013
00064 - AAA 014"""
00065 
00066         assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()
00067 
00068 
00069 coverage_modules = ['MoinMoin.util.diff_text']
00070