diff --git a/test/integration/__init__.py b/test/integration/__init__.py index 819d42a4ff..4beb44a203 100644 --- a/test/integration/__init__.py +++ b/test/integration/__init__.py @@ -6,6 +6,7 @@ import json import subprocess import sys +from pathlib import Path from test.testlib.testcase import BaseTestCase import cfnlint.core @@ -93,6 +94,9 @@ def run_module_integration_scenarios(self, rules): with open(results_filename, encoding="utf-8") as json_data: expected_results = json.load(json_data) + for result in expected_results: + result["Filename"] = str(Path(result.get("Filename"))) + template = cfnlint.decode.cfn_yaml.load(filename) matches = cfnlint.core.run_checks(filename, template, rules, regions) diff --git a/test/integration/test_directives.py b/test/integration/test_directives.py index 4ba45b7fed..519a985b1f 100644 --- a/test/integration/test_directives.py +++ b/test/integration/test_directives.py @@ -3,6 +3,7 @@ SPDX-License-Identifier: MIT-0 """ +from pathlib import Path from test.integration import BaseCliTestCase @@ -11,16 +12,18 @@ class TestDirectives(BaseCliTestCase): scenarios = [ { - "filename": "test/fixtures/templates/good/core/directives.yaml", + "filename": str(Path("test/fixtures/templates/good/core/directives.yaml")), "exit_code": 0, "results": [], }, { - "filename": "test/fixtures/templates/bad/core/directives.yaml", + "filename": str(Path("test/fixtures/templates/bad/core/directives.yaml")), "exit_code": 2, "results": [ { - "Filename": "test/fixtures/templates/bad/core/directives.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/directives.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 18, "LineNumber": 17}, @@ -41,7 +44,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/directives.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/directives.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 13, "LineNumber": 28}, @@ -62,7 +67,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/directives.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/directives.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 16, "LineNumber": 32}, @@ -82,7 +89,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/directives.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/directives.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 13, "LineNumber": 35}, @@ -103,7 +112,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/directives.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/directives.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 15, "LineNumber": 37}, diff --git a/test/integration/test_mandatory_checks.py b/test/integration/test_mandatory_checks.py index 1a1371cc9a..4abd928e35 100644 --- a/test/integration/test_mandatory_checks.py +++ b/test/integration/test_mandatory_checks.py @@ -3,6 +3,7 @@ SPDX-License-Identifier: MIT-0 """ +from pathlib import Path from test.integration import BaseCliTestCase @@ -11,11 +12,15 @@ class TestDirectives(BaseCliTestCase): scenarios = [ { - "filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml", + "filename": str( + Path("test/fixtures/templates/bad/core/mandatory_checks.yaml") + ), "exit_code": 2, "results": [ { - "Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/mandatory_checks.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 18, "LineNumber": 17}, @@ -36,7 +41,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/mandatory_checks.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 13, "LineNumber": 28}, @@ -57,7 +64,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/mandatory_checks.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 16, "LineNumber": 32}, @@ -77,7 +86,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/mandatory_checks.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 13, "LineNumber": 35}, @@ -98,7 +109,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/mandatory_checks.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 15, "LineNumber": 37}, @@ -120,7 +133,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/mandatory_checks.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 18, "LineNumber": 13}, @@ -141,7 +156,9 @@ class TestDirectives(BaseCliTestCase): }, }, { - "Filename": "test/fixtures/templates/bad/core/mandatory_checks.yaml", + "Filename": str( + Path("test/fixtures/templates/bad/core/mandatory_checks.yaml") + ), "Level": "Error", "Location": { "End": {"ColumnNumber": 16, "LineNumber": 19}, diff --git a/test/unit/module/formatters/test_formatters.py b/test/unit/module/formatters/test_formatters.py index 815e1123d7..41164f6dac 100644 --- a/test/unit/module/formatters/test_formatters.py +++ b/test/unit/module/formatters/test_formatters.py @@ -6,6 +6,7 @@ import json import sys import xml.etree.ElementTree as ET +from pathlib import Path from test.testlib.testcase import BaseTestCase import jsonschema @@ -27,7 +28,7 @@ class TestFormatters(BaseTestCase): def setUp(self) -> None: super().setUp() cfnlint.core._reset_rule_cache() - self.filename = "test/fixtures/templates/bad/formatters.yaml" + self.filename = str(Path("test/fixtures/templates/bad/formatters.yaml")) self.results = [ Match( 6,