From f6bbe1541f92dcd3277e2e77a44e6158f8acfbe6 Mon Sep 17 00:00:00 2001 From: Thomas Pierce Date: Thu, 19 Mar 2026 15:23:50 -0700 Subject: [PATCH] fix: replace deprecated pkg_resources with pathlib in benchmark test pkg_resources is no longer bundled by default in Python 3.12+, causing ModuleNotFoundError that blocks all test collection. Replace with pathlib which is stdlib and works on all supported versions. --- tests/test_local_sampling_benchmark.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/test_local_sampling_benchmark.py b/tests/test_local_sampling_benchmark.py index c98b89c7..eb76ea7d 100644 --- a/tests/test_local_sampling_benchmark.py +++ b/tests/test_local_sampling_benchmark.py @@ -1,17 +1,16 @@ import json import pkgutil -from pkg_resources import resource_filename +from pathlib import Path # Faster def test_pkgutil_static_read(benchmark): def get_sampling_rule(): - # `.decode('utf-8')` needed for Python 3.4, 3.5 return json.loads(pkgutil.get_data(__name__, 'mock_sampling_rule.json').decode('utf-8')) benchmark(get_sampling_rule) # Slower -def test_pkg_resources_static_read(benchmark): +def test_pathlib_static_read(benchmark): def get_sampling_rule(): - with open(resource_filename(__name__, 'mock_sampling_rule.json')) as f: + with open(Path(__file__).parent / 'mock_sampling_rule.json') as f: return json.load(f) benchmark(get_sampling_rule)