File: test_bashisms.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 (36 lines) | stat: -rw-r--r-- 1,340 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
from mockdata.mock_bashisms import BashismsPackage
import pytest
from rpmlint.checks.BashismsCheck import BashismsCheck
from rpmlint.filter import Filter

from Testing import CONFIG, HAS_CHECKBASHISMS, HAS_DASH


@pytest.fixture(scope='function', autouse=True)
def bashismscheck():
    CONFIG.info = True
    output = Filter(CONFIG)
    test = BashismsCheck(CONFIG, output)
    return output, test


@pytest.mark.skipif(not HAS_CHECKBASHISMS, reason='Optional dependency checkbashisms not installed')
@pytest.mark.skipif(not HAS_DASH, reason='Optional dependency dash not installed')
@pytest.mark.parametrize('package', [BashismsPackage])
def test_bashisms(package, bashismscheck):
    output, test = bashismscheck
    test.check(package)
    out = output.print_results(output.results)
    assert 'W: potential-bashisms /bin/script1' in out
    assert 'W: bin-sh-syntax-error /bin/script2' in out


@pytest.mark.skipif(not HAS_CHECKBASHISMS, reason='Optional dependency checkbashisms not installed')
@pytest.mark.skipif(not HAS_DASH, reason='Optional dependency dash not installed')
@pytest.mark.parametrize('package', [BashismsPackage])
def test_bashisms_error(package, bashismscheck):
    output, test = bashismscheck
    package.dirname = 'I-do-not-exist-for-sure'

    with pytest.raises(FileNotFoundError):
        test.check(package)