diff --git a/src/cfnlint/match.py b/src/cfnlint/match.py index 1916bd7335..57cce11747 100644 --- a/src/cfnlint/match.py +++ b/src/cfnlint/match.py @@ -7,6 +7,7 @@ import hashlib import uuid +from pathlib import Path from typing import TYPE_CHECKING if TYPE_CHECKING: @@ -56,7 +57,8 @@ def __init__( def __repr__(self): """Represent""" - file_str = self.filename + ":" if self.filename else "" + # use the Posix path to keep things consistent across platforms + file_str = Path(self.filename).as_posix() + ":" if self.filename else "" return f"[{self.rule}] ({self.message}) matched {file_str}{self.linenumber}" def __eq__(self, item): diff --git a/test/integration/test_good_templates.py b/test/integration/test_good_templates.py index 6f2f496d6c..a0d68d848f 100644 --- a/test/integration/test_good_templates.py +++ b/test/integration/test_good_templates.py @@ -3,6 +3,7 @@ SPDX-License-Identifier: MIT-0 """ +from pathlib import Path from test.integration import BaseCliTestCase from cfnlint import ConfigMixIn @@ -39,8 +40,10 @@ class TestQuickStartTemplates(BaseCliTestCase): ), "results": [ { - "Filename": ( - "test/fixtures/templates/bad/transform_serverless_template.yaml" + "Filename": str( + Path( + "test/fixtures/templates/bad/transform_serverless_template.yaml" + ) ), "Id": "74181426-e865-10eb-96fd-908dfd30a358", "Location": { @@ -70,8 +73,10 @@ class TestQuickStartTemplates(BaseCliTestCase): ), }, { - "Filename": ( - "test/fixtures/templates/bad/transform_serverless_template.yaml" + "Filename": str( + Path( + "test/fixtures/templates/bad/transform_serverless_template.yaml" + ) ), "Id": "fd751fa3-7d1f-e194-7108-eb08352814c8", "Location": { @@ -100,8 +105,10 @@ class TestQuickStartTemplates(BaseCliTestCase): ), }, { - "Filename": ( - "test/fixtures/templates/bad/transform_serverless_template.yaml" + "Filename": str( + Path( + "test/fixtures/templates/bad/transform_serverless_template.yaml" + ) ), "Id": "9e05773a-b0d0-f157-2955-596d9bd54749", "Location": { @@ -152,7 +159,11 @@ class TestQuickStartTemplates(BaseCliTestCase): "filename": "test/fixtures/templates/bad/resources_cognito_userpool_tag_is_list.yaml", "results": [ { - "Filename": "test/fixtures/templates/bad/resources_cognito_userpool_tag_is_list.yaml", + "Filename": str( + Path( + "test/fixtures/templates/bad/resources_cognito_userpool_tag_is_list.yaml" + ) + ), "Id": "3732b0a0-6d44-72af-860a-88e5f8ca790c", "Level": "Error", "Location": { @@ -201,8 +212,10 @@ class TestQuickStartTemplates(BaseCliTestCase): ), "results": [ { - "Filename": ( - "test/fixtures/templates/good/transform_serverless_globals.yaml" + "Filename": str( + Path( + "test/fixtures/templates/good/transform_serverless_globals.yaml" + ) ), "Id": "fc9f2534-f4f8-092b-52d6-dafd2d429b67", "Level": "Error",