Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Capture and hide ansible core warnings by default #3361

Merged
merged 1 commit into from
Apr 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions examples/playbooks/warning-from-module.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
# https://github.com/ansible/ansible-lint/issues/3216
- name: "Reproduce for bug #3216 warning from core module using Display.warning()"
hosts: localhost
gather_facts: false
tasks:
- name: Some task
ansible.builtin.debug:
msg: "{{ qq | unique }}"
vars:
qq: ["qq", "ww"]
4 changes: 4 additions & 0 deletions src/ansiblelint/rules/deprecated_bare_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,13 @@ def _matchvar(


if "pytest" in sys.modules:
import pytest

# pylint: disable=ungrouped-imports
from ansiblelint.rules import RulesCollection
from ansiblelint.runner import Runner

@pytest.mark.filterwarnings("ignore::ansible_compat.runtime.AnsibleWarning")
def test_use_bare_positive() -> None:
"""Positive test for deprecated-bare-vars."""
collection = RulesCollection()
Expand Down
1 change: 1 addition & 0 deletions src/ansiblelint/rules/yaml_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def _fetch_skips(data: Any, collector: dict[int, set[str]]) -> dict[int, set[str
),
),
)
@pytest.mark.filterwarnings("ignore::ansible_compat.runtime.AnsibleWarning")
def test_yamllint(file: str, expected_kind: str, expected: list[str]) -> None:
"""Validate parsing of ansible output."""
lintable = Lintable(file)
Expand Down