summaryrefslogtreecommitdiffstats
path: root/test/test_strict.py
blob: 9a15619fbd3df0b63b26bf03f9916da396b6408d (plain)
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
"""Test strict mode."""
import pytest

from ansiblelint.testing import run_ansible_lint


@pytest.mark.parametrize(
    ("strict", "returncode", "message"),
    (
        pytest.param(True, 2, "Failed", id="on"),
        pytest.param(False, 0, "Passed", id="off"),
    ),
)
def test_strict(strict: bool, returncode: int, message: str) -> None:
    """Test running from inside meta folder."""
    args = ["examples/playbooks/strict-mode.yml"]
    if strict:
        args.insert(0, "--strict")
    result = run_ansible_lint(*args)
    assert result.returncode == returncode
    assert "args[module]" in result.stdout
    for summary_line in result.stderr.splitlines():
        if summary_line.startswith(message):
            break
    else:
        pytest.fail(f"Failed to find {message} inside stderr output")