File: test_diff.py

package info (click to toggle)
rpmlint 2.8.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 8,308 kB
  • sloc: python: 20,622; ansic: 2,511; xml: 1,272; makefile: 17; sh: 4
file content (48 lines) | stat: -rw-r--r-- 1,759 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
from rpmlint.rpmdiff import Rpmdiff

from Testing import get_tested_path


def test_distribution_tags():
    oldpkg = get_tested_path('binary/mc-4.8.15-10.3.1.x86_64.rpm')
    newpkg = get_tested_path('binary/mc-4.8.21-2.1.x86_64.rpm')
    ignore = []
    diff = Rpmdiff(oldpkg, newpkg, ignore)
    textdiff = diff.textdiff()
    # the count always reports one less
    assert 231 <= len(textdiff.splitlines()) <= 233

    ignore.append('T')
    ignore.append('5')
    ignore.append('S')
    diff = Rpmdiff(oldpkg, newpkg, ignore)
    textdiff = diff.textdiff()
    assert 36 <= len(textdiff.splitlines()) <= 38

    assert 'added       /usr/share/mc/syntax/yaml.syntax' in textdiff


def test_exclude():
    oldpkg = get_tested_path('binary/mc-4.8.15-10.3.1.x86_64.rpm')
    newpkg = get_tested_path('binary/mc-4.8.21-2.1.x86_64.rpm')
    ignore = list('T5S')

    # print(Rpmdiff(oldpkg, newpkg, ignore=ignore).textdiff())

    for exclude in [], ['/usr/share/mc/ski'], ['/share/mc/skins'], ['skins']:
        diff = Rpmdiff(oldpkg, newpkg, ignore, exclude)
        textdiff = diff.textdiff()
        assert '/usr/share/mc/skins/yadt256.ini' in textdiff

    for exclude in (['/usr/share/mc/skins'], ['/usr/share/*/skins'],
                    ['/*/*/*/skins']):
        diff = Rpmdiff(oldpkg, newpkg, ignore, exclude)
        textdiff = diff.textdiff()
        assert '/usr/share/mc/skins/yadt256.ini' not in textdiff
        assert '/usr/share/mc/syntax/cuda.syntax' in textdiff

    for exclude in ['*.syntax'], ['syntax/cuda.syntax']:
        diff = Rpmdiff(oldpkg, newpkg, ignore, exclude)
        textdiff = diff.textdiff()
        assert '/usr/share/mc/skins/yadt256.ini' in textdiff
        assert '/usr/share/mc/syntax/cuda.syntax' not in textdiff