From ab675b8660593f249316a184d600292c098033c1 Mon Sep 17 00:00:00 2001 From: willGraham01 <1willgraham@gmail.com> Date: Tue, 14 Nov 2023 16:43:49 +0000 Subject: [PATCH] Direct filepaths to be absolute, since tests are not packaged. --- tests/tests/test_unit/test_analyse.py | 15 +++++++++------ tox.ini | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/tests/test_unit/test_analyse.py b/tests/tests/test_unit/test_analyse.py index 01b3910a..12c107e1 100644 --- a/tests/tests/test_unit/test_analyse.py +++ b/tests/tests/test_unit/test_analyse.py @@ -1,5 +1,5 @@ import filecmp -from importlib.resources import files +import os from pathlib import Path import pytest @@ -37,15 +37,18 @@ def structures_with_points(): def test_get_region_totals(tmp_path, points, structures_with_points): """Regression test for get_region_totals for pandas 1.5.3 -> 2.1.3+. pd.Dataframe.append was deprecated and remove in this time.""" - volumes_path = files("cellfinder").joinpath( - "../tests/data/analyse/volumes.csv" + OUTPUT_DATA_LOC = ( + Path(os.path.dirname(os.path.abspath(__file__))) / "../../data/analyse" + ).resolve() + + volumes_path = OUTPUT_DATA_LOC / "volumes.csv" + expected_output = ( + OUTPUT_DATA_LOC / "region_totals_regression_pandas1_5_3.csv" ) + output_path = Path(tmp_path / "tmp_region_totals.csv") get_region_totals( points, structures_with_points, volumes_path, output_path ) assert output_path.exists() - expected_output = files("cellfinder").joinpath( - "../tests/data/analyse/region_totals_regression_pandas1_5_3.csv" - ) assert filecmp.cmp(output_path, expected_output) diff --git a/tox.ini b/tox.ini index 78a015dc..d34ad63e 100644 --- a/tox.ini +++ b/tox.ini @@ -14,7 +14,7 @@ INPUT_COREDEV = true: coredev [testenv] -commands = pytest -v --cov=./ --cov-report=xml +commands = pytest {toxinidir} -v --cov=./ --cov-report=xml deps = pytest-cov pytest