diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index be5f5eba..c24f40e3 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -15,10 +15,10 @@ jobs: - macos-latest # - windows-latest python: - - "3.8" - "3.9" - "3.10" - "3.11" + - "3.12" ipfs: - "0.28" - "0.29" diff --git a/ipwb/error_handler.py b/ipwb/error_handler.py index a00e0138..06242fbd 100644 --- a/ipwb/error_handler.py +++ b/ipwb/error_handler.py @@ -7,7 +7,7 @@ def exception_logger(catch=True, exception_class=Exception): """ - Decorator which catches exceptions in the function and logs them. + Decorator that catches exceptions in the function and logs them. Usage: @@ -17,11 +17,11 @@ def decorated_function(foo, bar): do_something ``` - `exception_logger()` will catch any exception which happens in + `exception_logger()` will catch any exception that happens in `decorated_function()` while it is being executed, and log an error using Python built in `logging` library. - Unless `catch` argument is `False` - in which case the exception will be + Unless `catch` argument is `False` - in which case, the exception will be reraised. """ def decorator(f: Callable): diff --git a/ipwb/replay.py b/ipwb/replay.py index 8608d861..cedbaaeb 100755 --- a/ipwb/replay.py +++ b/ipwb/replay.py @@ -11,10 +11,10 @@ import sys import os +import importlib.resources import ipfshttpclient as ipfsapi import json import subprocess -import pkg_resources import surt import re import traceback @@ -1018,8 +1018,8 @@ def get_index_file_full_path(cdxj_file_path=INDEX_FILE): if os.path.isfile(cdxj_file_path): return cdxj_file_path - index_file_name = pkg_resources.resource_filename( - __name__, index_file_path) + index_file_name = importlib.resources.files( + __name__).joinpath(index_file_path) return index_file_name diff --git a/ipwb/util.py b/ipwb/util.py index 02e9cea0..1ebf6d96 100644 --- a/ipwb/util.py +++ b/ipwb/util.py @@ -24,7 +24,7 @@ from ipfshttpclient.exceptions import ConnectionError, AddressError from multiaddr.exceptions import StringParseError -from pkg_resources import parse_version +from packaging.version import parse as parse_version from .exceptions import IPFSDaemonNotAvailable diff --git a/requirements.txt b/requirements.txt index 41cb2a45..b3d2453f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ requests>=2.19.1 beautifulsoup4>=4.6.3 surt>=0.3.0 multiaddr >= 0.0.9 +packaging==23.0 diff --git a/test-requirements.txt b/test-requirements.txt index 4da99efc..d0f1b941 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -2,3 +2,4 @@ flake8>=3.7.9 pytest>=5.3.5 pytest-cov pytest-flake8 +setuptools diff --git a/tests/test_error_handler.py b/tests/test_error_handler.py index 573af3ee..74609011 100644 --- a/tests/test_error_handler.py +++ b/tests/test_error_handler.py @@ -1,5 +1,5 @@ import pytest -from unittest.mock import MagicMock, patch +from unittest.mock import MagicMock, patch, ANY from ipwb.error_handler import exception_logger @@ -24,4 +24,4 @@ def test_catch(): with patch('ipwb.error_handler.logger.critical', mock_logger): caught_error('boo') - assert mock_logger.called_once_with(('boo', )) + mock_logger.assert_called_once_with('boo')