~ubuntu-branches/ubuntu/natty/moin/natty-updates

« back to all changes in this revision

Viewing changes to MoinMoin/util/_tests/test_diff_text.py

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2008-06-22 21:17:13 UTC
  • mfrom: (0.9.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080622211713-fpo2zrq3s5dfecxg
Tags: 1.7.0-3
Simplify /etc/moin/wikilist format: "USER URL" (drop unneeded middle
CONFIG_DIR that was wrongly advertised as DATA_DIR).  Make
moin-mass-migrate handle both formats and warn about deprecation of
the old one.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# -*- coding: utf-8 -*-
 
2
"""
 
3
    MoinMoin - MoinMoin.util.diff_text Tests
 
4
 
 
5
    @copyright: 2007 MoinMoin:ThomasWaldmann
 
6
    @license: GNU GPL, see COPYING for details.
 
7
"""
 
8
 
 
9
from MoinMoin.util import diff_text
 
10
 
 
11
class TestDiffText:
 
12
 
 
13
    def testDiff(self):
 
14
        """ util.diff_text.diff: test correct diff calculation """
 
15
        in1 = """AAA 001
 
16
AAA 002
 
17
AAA 003
 
18
AAA 004
 
19
AAA 005
 
20
AAA 006
 
21
AAA 007
 
22
AAA 008
 
23
AAA 009
 
24
AAA 010
 
25
AAA 011
 
26
AAA 012
 
27
AAA 013
 
28
AAA 014
 
29
"""
 
30
 
 
31
        in2 = """AAA 001
 
32
AAA 002
 
33
AAA 005
 
34
AAA 006
 
35
AAA 007
 
36
AAA 008
 
37
BBB 001
 
38
BBB 002
 
39
AAA 009
 
40
AAA 010
 
41
BBB 003
 
42
"""
 
43
 
 
44
        result = diff_text.diff(in1.splitlines(), in2.splitlines())
 
45
        result = "\n".join(result)
 
46
 
 
47
        expected = """\
 
48
  AAA 001
 
49
  AAA 002
 
50
- AAA 003
 
51
- AAA 004
 
52
  AAA 005
 
53
  AAA 006
 
54
  AAA 007
 
55
  AAA 008
 
56
+ BBB 001
 
57
+ BBB 002
 
58
  AAA 009
 
59
  AAA 010
 
60
+ BBB 003
 
61
- AAA 011
 
62
- AAA 012
 
63
- AAA 013
 
64
- AAA 014"""
 
65
 
 
66
        assert result == expected, ('Expected "%(expected)s" but got "%(result)s"') % locals()
 
67
 
 
68
 
 
69
coverage_modules = ['MoinMoin.util.diff_text']
 
70