Skip to content

Commit

Permalink
retrieve executable from runtime
Browse files Browse the repository at this point in the history
* avoid hard coded executbale path by asking runtime path
* guard file removal during cleanup

Signed-off-by: Jeffrey Martin <[email protected]>
  • Loading branch information
jmartin-tech committed Apr 23, 2024
1 parent 2ff210d commit d68b3b6
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions tests/analyze/test_analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

import os
import subprocess
import sys

import pytest

Expand All @@ -18,15 +19,25 @@ def garak_tiny_run() -> None:

def test_analyze_log_runs():
result = subprocess.run(
["python3", "-m", "garak.analyze.analyze_log", temp_prefix + ".report.jsonl"],
[
sys.executable,
"-m",
"garak.analyze.analyze_log",
temp_prefix + ".report.jsonl",
],
check=True,
)
assert result.returncode == 0


def test_report_digest_runs():
result = subprocess.run(
["python3", "-m", "garak.analyze.report_digest", temp_prefix + ".report.jsonl"],
[
sys.executable,
"-m",
"garak.analyze.report_digest",
temp_prefix + ".report.jsonl",
],
check=True,
)
assert result.returncode == 0
Expand All @@ -37,7 +48,14 @@ def cleanup(request):
"""Cleanup a testing directory once we are finished."""

def remove_logs():
os.remove(temp_prefix + ".report.jsonl")
os.remove(temp_prefix + ".report.html")
logs = [
temp_prefix + ".report.jsonl",
temp_prefix + ".report.html",
]
for file in logs:
try:
os.remove(file)
except FileNotFoundError:
pass

request.addfinalizer(remove_logs)

0 comments on commit d68b3b6

Please sign in to comment.