From 5a646d6bd84625264f7dddd88052f28ce998d8e4 Mon Sep 17 00:00:00 2001 From: solarsys Date: Mon, 12 Oct 2026 13:55:06 -0700 Subject: [PATCH] Find test resources relative to the test file, not the working directory test_sdoh and nlp/test_metrics read test-resources/... relative to the current directory, so they failed whenever the suite was run from anywhere but the repo root (for example the documented 'cd tests && python -m unittest core.x'). Resolve the paths from __file__, as the other tests already do. Co-Authored-By: Claude Opus 5.5 --- tests/core/test_sdoh.py | 6 +++++- tests/nlp/test_metrics.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/core/test_sdoh.py b/tests/core/test_sdoh.py index defa1b1ae..fd60831c1 100644 --- a/tests/core/test_sdoh.py +++ b/tests/core/test_sdoh.py @@ -1,3 +1,4 @@ +from pathlib import Path from typing import Set from tests.base import BaseTestCase from pyhealth.models.sdoh import SdohClassifier @@ -25,7 +26,10 @@ def test_is_initialized_nn_module(self): def test_parse_reponse(self): """Test the parsing of the SDOH output.""" import pandas as pd - df = pd.read_csv('test-resources/core/sdoh-test-cases.csv') + cases = ( + Path(__file__).parents[2] / "test-resources" / "core" / "sdoh-test-cases.csv" + ) + df = pd.read_csv(cases) sdoh = SdohClassifier() response: str preds: str diff --git a/tests/nlp/test_metrics.py b/tests/nlp/test_metrics.py index a0fd76a68..0b9cfa6d3 100644 --- a/tests/nlp/test_metrics.py +++ b/tests/nlp/test_metrics.py @@ -36,7 +36,9 @@ def test_object_graph(self): def test_pandas(self): WRITE: bool = 0 - should_file: Path = Path('test-resources/nlp/metrics.csv') + should_file: Path = ( + Path(__file__).parents[2] / "test-resources" / "nlp" / "metrics.csv" + ) self._set_debug() scorer = Scorer() ss: ScoreSet = scorer.score(ScoreContext(self.pairs))