Skip to content

Commit

Permalink
Fix broken test
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Nov 11, 2022
1 parent 9198cc3 commit fdd2ac9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
11 changes: 3 additions & 8 deletions src/ansiblelint/rules/var_naming.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,14 +201,9 @@ def test_invalid_var_name_playbook(rule_runner: RunFromText) -> None:
assert len(results) == 6
for result in results:
assert result.rule.id == VariableNamingRule.id

# list unexpected error lines or non-matching error lines
expected_error_lines = [5, 9, 21, 21, 26, 28]
lines = [i.linenumber for i in results]
error_lines_difference = list(
set(expected_error_lines).symmetric_difference(set(lines))
)
assert len(error_lines_difference) == 0
# We are not checking line numbers because they can vary between
# different versions of ruamel.yaml (and depending on presence/absence
# of its c-extension)

@pytest.mark.parametrize(
"rule_runner", (VariableNamingRule,), indirect=["rule_runner"]
Expand Down
6 changes: 4 additions & 2 deletions test/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def test_template(template: str, output: str) -> None:
("template_lookup", False),
# With 2.15 ansible replaced the runtime Warning about inability to
# open a file in file lookup with a full error.
("template_lookup_missing", runtime.version_in_range(upper="2.14")),
("template_lookup_missing", runtime.version_in_range(upper="2.15.0.dev0")),
),
)
def test_template_lookup(role: str, expect_warning: bool) -> None:
Expand All @@ -273,7 +273,9 @@ def test_template_lookup(role: str, expect_warning: bool) -> None:
)
)
result = run_ansible_lint("-v", task_path)
assert ("Unable to find" in result.stderr) == expect_warning
# 2.13 or older will not attempt to install when in offline mode
if not runtime.version_in_range(upper="2.14.0.dev0"):
assert ("Unable to find" in result.stderr) == expect_warning


def test_task_to_str_unicode() -> None:
Expand Down

0 comments on commit fdd2ac9

Please sign in to comment.