From b889ea329acd4f51c7c2e337de482014eeb02e7c Mon Sep 17 00:00:00 2001 From: burnettk Date: Thu, 15 Aug 2024 08:52:47 -0400 Subject: [PATCH] allow pytest to work from root or wait-for-ecr-scan-and-get-sarif --- .../test_aws_scan_findings_to_sarif.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/wait-for-ecr-scan-and-get-sarif/test_aws_scan_findings_to_sarif.py b/wait-for-ecr-scan-and-get-sarif/test_aws_scan_findings_to_sarif.py index 317343e..6875a29 100644 --- a/wait-for-ecr-scan-and-get-sarif/test_aws_scan_findings_to_sarif.py +++ b/wait-for-ecr-scan-and-get-sarif/test_aws_scan_findings_to_sarif.py @@ -1,9 +1,14 @@ import json import pytest +import os +import sys +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from aws_scan_findings_to_sarif import convert_to_sarif def test_convert_to_sarif(): - with open("sample-api-response-ecr-describe-image-scan-findings.json", "r") as f: + base_dir = os.path.dirname(os.path.abspath(__file__)) + sample_file_path = os.path.join(base_dir, "sample-api-response-ecr-describe-image-scan-findings.json") + with open(sample_file_path, "r") as f: ecr_response = json.load(f) sarif_report = convert_to_sarif(ecr_response)