From 5face4ef6d3a3e5d46a1851f17b9efcb08ef7e9b Mon Sep 17 00:00:00 2001 From: spark Date: Wed, 28 Oct 2026 23:22:33 +0000 Subject: [PATCH] spark: Fix test script to use absolute paths for portable testing --- wizard-work/spark/test_line_counter.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/wizard-work/spark/test_line_counter.py b/wizard-work/spark/test_line_counter.py index 73b2c3a..1c6a03f 100644 --- a/wizard-work/spark/test_line_counter.py +++ b/wizard-work/spark/test_line_counter.py @@ -3,6 +3,9 @@ import subprocess import sys +import os + +BASE_DIR = os.path.dirname(os.path.abspath(__file__)) def run_test(cmd, expected, description): """Run a test command and verify output.""" @@ -19,21 +22,21 @@ def run_test(cmd, expected, description): # Test CSV mode with known data test_csv_pass = run_test( - ['python3', 'line_counter.py', 'test_data.csv', 'csv'], + ['python3', f'{BASE_DIR}/line_counter.py', f'{BASE_DIR}/test_data.csv', 'csv'], 5, "CSV count mode (5 items)" ) # Test count mode with known lines test_count_pass = run_test( - ['python3', 'line_counter.py', 'test_log.txt', 'count'], + ['python3', f'{BASE_DIR}/line_counter.py', f'{BASE_DIR}/test_log.txt', 'count'], 10, "Line count mode (10 lines)" ) # Test error handling for non-existent file result = subprocess.run( - ['python3', 'line_counter.py', 'nonexistent.txt', 'count'], + ['python3', f'{BASE_DIR}/line_counter.py', f'{BASE_DIR}/nonexistent.txt', 'count'], capture_output=True, text=True )