summaryrefslogtreecommitdiffstats
path: root/test/test_strict.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_strict.py')
-rw-r--r--test/test_strict.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/test_strict.py b/test/test_strict.py
new file mode 100644
index 0000000..9a15619
--- /dev/null
+++ b/test/test_strict.py
@@ -0,0 +1,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")