Fix hardcoded paths in test files and improve YAML error handling

- Replace hardcoded absolute paths with relative paths using Path(__file__).parent
- Update test_activity_flows.py, test_guarded_ai.py, and test_battleship_pre_script.py to use dynamic path construction
- Import yaml module and catch yaml.YAMLError instead of broad Exception in test_activity_processing.py
- Ensures tests work across different environments and CI systems
- Makes YAML error handling more specific and prevents masking other exceptions
This commit is contained in:
Russell Ballestrini 2025-08-10 21:06:10 -04:00
parent 092ebd0ee0
commit 6b876d488c
6 changed files with 22 additions and 19 deletions

View file

@ -11,6 +11,7 @@ import tempfile
import json
import sys
import os
import yaml
from unittest.mock import Mock, patch, MagicMock
from pathlib import Path
@ -446,7 +447,7 @@ script_result = {'status': 'error'}
with open(test_file, "w") as f:
f.write(malformed_yaml)
with self.assertRaises(Exception): # YAML parsing error
with self.assertRaises(yaml.YAMLError): # YAML parsing error
app.get_activity_content("research/malformed.yaml")
finally: