Skip to content

Commit fb91200

Browse files
authored
Merge pull request #485 from thpierce/fix/pkg-resources-removal
fix: replace deprecated pkg_resources with pathlib in benchmark test
2 parents 386902b + f6bbe15 commit fb91200

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import json
22
import pkgutil
3-
from pkg_resources import resource_filename
3+
from pathlib import Path
44

55
# Faster
66
def test_pkgutil_static_read(benchmark):
77
def get_sampling_rule():
8-
# `.decode('utf-8')` needed for Python 3.4, 3.5
98
return json.loads(pkgutil.get_data(__name__, 'mock_sampling_rule.json').decode('utf-8'))
109
benchmark(get_sampling_rule)
1110

1211
# Slower
13-
def test_pkg_resources_static_read(benchmark):
12+
def test_pathlib_static_read(benchmark):
1413
def get_sampling_rule():
15-
with open(resource_filename(__name__, 'mock_sampling_rule.json')) as f:
14+
with open(Path(__file__).parent / 'mock_sampling_rule.json') as f:
1615
return json.load(f)
1716
benchmark(get_sampling_rule)

0 commit comments

Comments
 (0)