aio-libs / aio-libs/aiocache

Test failures with Python 3.13.0b2

Open
#863 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
1.4k
Forks
181
PR merge metrics
No merged PRs in 30d

Description

When running the test suite with Python 3.13.0b2, I'm getting the following failures (all tests pass with 3.12):

```pytb
$ python -m pytest --ignore tests/performance/
========================================================= test session starts =========================================================
platform linux -- Python 3.13.0b2, pytest-8.2.2, pluggy-1.5.0
rootdir: /tmp/aiocache
configfile: setup.cfg
testpaths: tests/
plugins: mock-3.14.0, asyncio-0.23.7, cov-5.0.0
asyncio: mode=Mode.AUTO
collected 801 items

tests/acceptance/test_base.py .......................................................................................... [ 11%]
tests/acceptance/test_decorators.py ............................................. [ 16%]
tests/acceptance/test_factory.py ....... [ 17%]
tests/acceptance/test_lock.py ................................................F...... [ 24%]
tests/acceptance/test_plugins.py ............. [ 26%]
tests/acceptance/test_serializers.py .......................................................................................... [ 37%]
..................................................................................................................... [ 52%]
tests/ut/backends/test_memcached.py ............................................ [ 57%]
tests/ut/backends/test_memory.py ................................ [ 61%]
tests/ut/backends/test_redis.py ................................... [ 65%]
tests/ut/test_base.py .................................................................................... [ 76%]
tests/ut/test_decorators.py .................F..............................F.............. [ 84%]
tests/ut/test_exceptions.py . [ 84%]
tests/ut/test_factory.py ........................................... [ 89%]
tests/ut/test_lock.py .............. [ 91%]
tests/ut/test_plugins.py ....... [ 92%]
tests/ut/test_serializers.py ............................................................. [100%]

============================================================== FAILURES ===============================================================
___________________________________ TestOptimisticLock.test_check_and_set_with_int_ttl[redis_cache] ___________________________________

self = , cache = RedisCache (127.0.0.1:6379)
lock =

async def test_check_and_set_with_int_ttl(self, cache, lock):
await cache.set(Keys.KEY, "previous_value")
async with lock as locked:
await locked.cas("value", ttl=1)

await asyncio.sleep(1)
> assert await cache.get(Keys.KEY) is None
E AssertionError: assert 'value' is None

tests/acceptance/test_lock.py:237: AssertionError
_________________________________________ TestCached.test_cache_write_doesnt_wait_for_future __________________________________________

self = , args = ("stub()[('value', 'value')]", 'value'), kwargs = {}
msg = "Expected 'set_in_cache' to be called once. Called 0 times."

def assert_called_once_with(self, /, *args, **kwargs):
"""assert that the mock was called exactly once and that that call was
with the specified arguments."""
if not self.call_count == 1:
msg = ("Expected '%s' to be called once. Called %s times.%s"
% (self._mock_name or 'mock',
self.call_count,
self._calls_repr()))
> raise AssertionError(msg)
E AssertionError: Expected 'set_in_cache' to be called once. Called 0 times.

/usr/lib/python3.13/unittest/mock.py:985: AssertionError

During handling of the above exception, another exception occurred:

self =
mocker = , decorator =
decorator_call =

async def test_cache_write_doesnt_wait_for_future(self, mocker, decorator, decorator_call):
mocker.spy(decorator, "set_in_cache")
with patch.object(decorator, "get_from_cache", autospec=True, return_value=None):
with patch("aiocache.decorators.asyncio.ensure_future", autospec=True):
await decorator_call(aiocache_wait_for_write=False, value="value")

decorator.set_in_cache.assert_not_awaited()
> decorator.set_in_cache.assert_called_once_with("stub()[('value', 'value')]", "value")

tests/ut/test_decorators.py:172:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ("stub()[('value', 'value')]", 'value'), kwargs = {}

def assert_called_once_with(*args, **kwargs):
> return mock.assert_called_once_with(*args, **kwargs)
E AssertionError: Expected 'set_in_cache' to be called once. Called 0 times.

/usr/lib/python3.13/unittest/mock.py:244: AssertionError
_______________________________________ TestMultiCached.test_cache_write_doesnt_wait_for_future _______________________________________

self =
args = ({'a': , 'b': }, , , ), kwargs = {}
msg = "Expected 'set_in_cache' to be called once. Called 0 times."

def assert_called_once_with(self, /, *args, **kwargs):
"""assert that the mock was called exactly once and that that call was
with the specified arguments."""
if not self.call_count == 1:
msg = ("Expected '%s' to be called once. Called %s times.%s"
% (self._mock_name or 'mock',
self.call_count,
self._calls_repr()))
> raise AssertionError(msg)
E AssertionError: Expected 'set_in_cache' to be called once. Called 0 times.

/usr/lib/python3.13/unittest/mock.py:985: AssertionError

During handling of the above exception, another exception occurred:

self =
mocker =
decorator = , decorator_call =

async def test_cache_write_doesnt_wait_for_future(self, mocker, decorator, decorator_call):
mocker.spy(decorator, "set_in_cache")
with patch.object(decorator, "get_from_cache", autospec=True, return_value=[None, None]):
with patch("aiocache.decorators.asyncio.ensure_future", autospec=True):
await decorator_call(1, keys=["a", "b"], value="value",
aiocache_wait_for_write=False)

decorator.set_in_cache.assert_not_awaited()
> decorator.set_in_cache.assert_called_once_with({"a": ANY, "b": ANY}, stub_dict, ANY, ANY)

tests/ut/test_decorators.py:483:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

args = ({'a': , 'b': }, , , ), kwargs = {}

def assert_called_once_with(*args, **kwargs):
> return mock.assert_called_once_with(*args, **kwargs)
E AssertionError: Expected 'set_in_cache' to be called once. Called 0 times.

/usr/lib/python3.13/unittest/mock.py:244: AssertionError

----------- coverage: platform linux, python 3.13.0-beta-2 -----------
Name Stmts Miss Cover
-----------------------------------------------------------
aiocache/__init__.py 24 4 83%
aiocache/backends/__init__.py 0 0 100%
aiocache/backends/memcached.py 99 0 100%
aiocache/backends/memory.py 86 0 100%
aiocache/backends/redis.py 107 0 100%
aiocache/base.py 275 2 99%
aiocache/decorators.py 164 0 100%
aiocache/exceptions.py 2 0 100%
aiocache/factory.py 101 0 100%
aiocache/lock.py 52 0 100%
aiocache/plugins.py 47 0 100%
aiocache/serializers/__init__.py 10 2 80%
aiocache/serializers/serializers.py 66 3 95%
tests/__init__.py 0 0 100%
tests/acceptance/__init__.py 0 0 100%
tests/acceptance/conftest.py 26 0 100%
tests/acceptance/test_base.py 180 0 100%
tests/acceptance/test_decorators.py 148 0 100%
tests/acceptance/test_factory.py 35 0 100%
tests/acceptance/test_lock.py 209 0 100%
tests/acceptance/test_plugins.py 43 0 100%
tests/acceptance/test_serializers.py 112 0 100%
tests/conftest.py 12 0 100%
tests/performance/__init__.py 0 0 100%
tests/performance/conftest.py 11 11 0%
tests/performance/server.py 37 37 0%
tests/performance/test_concurrency.py 27 27 0%
tests/performance/test_footprint.py 107 107 0%
tests/ut/__init__.py 0 0 100%
tests/ut/backends/__init__.py 0 0 100%
tests/ut/backends/test_memcached.py 192 0 100%
tests/ut/backends/test_memory.py 158 0 100%
tests/ut/backends/test_redis.py 138 0 100%
tests/ut/conftest.py 40 0 100%
tests/ut/test_base.py 414 0 100%
tests/ut/test_decorators.py 399 1 99%
tests/ut/test_exceptions.py 3 0 100%
tests/ut/test_factory.py 163 4 98%
tests/ut/test_lock.py 87 0 100%
tests/ut/test_plugins.py 58 0 100%
tests/ut/test_serializers.py 118 0 100%
tests/utils.py 47 2 96%
-----------------------------------------------------------
TOTAL 3797 200 95%

======================================================= short test summary info =======================================================
FAILED tests/acceptance/test_lock.py::TestOptimisticLock::test_check_and_set_with_int_ttl[redis_cache] - AssertionError: assert 'value' is None
FAILED tests/ut/test_decorators.py::TestCached::test_cache_write_doesnt_wait_for_future - AssertionError: Expected 'set_in_cache' to be called once. Called 0 times.
FAILED tests/ut/test_decorators.py::TestMultiCached::test_cache_write_doesnt_wait_for_future - AssertionError: Expected 'set_in_cache' to be called once. Called 0 times.
============================================== 3 failed, 798 passed in 116.84s (0:01:56) ==============================================
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.