diff --git a/aiocache/decorators.py b/aiocache/decorators.py index 92e4fe93..86499b80 100644 --- a/aiocache/decorators.py +++ b/aiocache/decorators.py @@ -82,7 +82,7 @@ def __call__(self, f): self.cache = caches.get(self.alias) for arg in ("serializer", "namespace", "plugins"): if getattr(self, f'_{arg}', None) is not None: - logger.warning(f"Using cache alias; ignoring '{arg}' argument.") + logger.warning(f"Using cache alias; ignoring {arg!r} argument.") else: self.cache = _get_cache( cache=self._cache, @@ -310,7 +310,7 @@ def __call__(self, f): self.cache = caches.get(self.alias) for arg in ("serializer", "namespace", "plugins"): if getattr(self, f'_{arg}', None) is not None: - logger.warning(f"Using cache alias; ignoring '{arg}' argument.") + logger.warning(f"Using cache alias; ignoring {arg!r} argument.") else: self.cache = _get_cache( cache=self._cache, diff --git a/requirements-dev.txt b/requirements-dev.txt index 1a9e2dff..af99a537 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -2,7 +2,7 @@ flake8==6.0.0 flake8-bandit==4.1.1 -flake8-bugbear==22.12.6 +flake8-bugbear==23.1.20 flake8-import-order==0.18.2 flake8-requirements==1.7.6 mypy==0.991; implementation_name=="cpython" diff --git a/tests/ut/conftest.py b/tests/ut/conftest.py index c600e947..0adcd1f4 100644 --- a/tests/ut/conftest.py +++ b/tests/ut/conftest.py @@ -29,7 +29,7 @@ def reset_caches(): @pytest.fixture def mock_cache(mocker): - return create_autospec(BaseCache, instance=True) + return create_autospec(BaseCache()) @pytest.fixture diff --git a/tests/ut/test_decorators.py b/tests/ut/test_decorators.py index b1a49ffa..4b0ebdab 100644 --- a/tests/ut/test_decorators.py +++ b/tests/ut/test_decorators.py @@ -151,8 +151,8 @@ async def test_calls_fn_set_when_get_none(self, mocker, decorator, decorator_cal async def test_calls_fn_raises_exception(self, decorator, decorator_call): decorator.cache.get.return_value = None - stub.side_effect = Exception() - with pytest.raises(Exception): + stub.side_effect = Exception("foo") + with pytest.raises(Exception, match="foo"): assert await decorator_call() async def test_cache_write_waits_for_future(self, decorator, decorator_call): @@ -284,8 +284,8 @@ async def test_calls_get_and_returns(self, decorator, decorator_call): async def test_calls_fn_raises_exception(self, decorator, decorator_call): decorator.cache.get.return_value = None - stub.side_effect = Exception() - with pytest.raises(Exception): + stub.side_effect = Exception("foo") + with pytest.raises(Exception, match="foo"): assert await decorator_call() async def test_calls_redlock(self, decorator, decorator_call): @@ -492,8 +492,8 @@ async def test_calls_fn_with_only_missing_keys(self, mocker, decorator, decorato async def test_calls_fn_raises_exception(self, decorator, decorator_call): decorator.cache.multi_get.return_value = [None] - stub_dict.side_effect = Exception() - with pytest.raises(Exception): + stub_dict.side_effect = Exception("foo") + with pytest.raises(Exception, match="foo"): assert await decorator_call(keys=[]) async def test_cache_read_disabled(self, decorator, decorator_call):