From b7dfcc7d579c2e2ffd6d4b940bbf33ba080e7997 Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Sun, 22 Dec 2024 13:47:19 +0100 Subject: [PATCH 1/2] Remove importlib_requests --- dev-spec.txt | 1 - recipe/meta.yaml | 1 - 2 files changed, 2 deletions(-) diff --git a/dev-spec.txt b/dev-spec.txt index 3638e4c9..d9f32a07 100644 --- a/dev-spec.txt +++ b/dev-spec.txt @@ -4,7 +4,6 @@ # Base python>=3.9 cartopy -importlib_resources matplotlib-base numpy progressbar2 diff --git a/recipe/meta.yaml b/recipe/meta.yaml index 8682e576..2d73d86a 100644 --- a/recipe/meta.yaml +++ b/recipe/meta.yaml @@ -31,7 +31,6 @@ requirements: run: - python >=3.9 - cartopy - - importlib_resources - matplotlib-base - numpy - progressbar2 From b507df5e133076adc5c3ccbfdaec9b8a498aa91a Mon Sep 17 00:00:00 2001 From: Xylar Asay-Davis Date: Sun, 22 Dec 2024 13:52:40 +0100 Subject: [PATCH 2/2] Fix test_features_and_tags We need to find `geometric_features/features_and_tags.json` using `importlib.resources` and we want to store the comparison file in the temporary directory generated for the test, not the current directory. --- geometric_features/test/test_features_and_tags.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/geometric_features/test/test_features_and_tags.py b/geometric_features/test/test_features_and_tags.py index e1892b20..4bef4979 100644 --- a/geometric_features/test/test_features_and_tags.py +++ b/geometric_features/test/test_features_and_tags.py @@ -1,21 +1,29 @@ import difflib import os +from importlib.resources import files as imp_res_files -from geometric_features.test import TestCase +import pytest + +from geometric_features.test import TestCase, loaddatadir # noqa: F401 from geometric_features.utils import write_feature_names_and_tags +@pytest.mark.usefixtures('loaddatadir') class TestFeaturesAndTags(TestCase): def test_features_and_tags(self): if 'GEOMETRIC_DATA_DIR' in os.environ: cache_location = os.environ['GEOMETRIC_DATA_DIR'] else: - cache_location = './geometric_data' + cache_location = os.path.abspath('./geometric_data') + + os.chdir(self.datadir) + write_feature_names_and_tags(cacheLocation=cache_location, quiet=True) assert os.path.exists('features_and_tags.json') - filename1 = 'geometric_features/features_and_tags.json' + filename1 = str(imp_res_files('geometric_features') / + 'features_and_tags.json') filename2 = 'features_and_tags.json' with open(filename1, 'r') as f: lines1 = f.readlines()