grantjenks / python-diskcache

Python disk-backed cache (Django-compatible). Faster than Redis and Memcached. Pure-Python.

Home Page:http://www.grantjenks.com/docs/diskcache/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

django 4.1 incompatibility

gador opened this issue · comments

Hi,

when using diskcache with the newer django framework 4.1, one of the tests fail:

============================= test session starts ==============================
platform linux -- Python 3.10.5, pytest-7.1.2, pluggy-1.0.0
rootdir: /build/source, configfile: tox.ini
plugins: django-4.5.2, xdist-2.5.0, forked-1.4.0
^Mgw0 I / gw1 I / gw2 I / gw3 I / gw4 I / gw5 I / gw6 I / gw7 I^Mgw0 C / gw1 I / gw2 I / gw3>
...........F............................................................ [ 30%]
........................................................................ [ 60%]
........................................................................ [ 91%]
.....................                                                    [100%]
=================================== FAILURES ===================================
______________ DiskCacheTests.test_cache_write_unpicklable_object ______________
[gw5] linux -- Python 3.10.5 /nix/store/rc9cz7z4qlgmsbwvpw2acig5g2rdws46-python3-3.10.5/bin/>
self = <tests.test_djangocache.DiskCacheTests testMethod=test_cache_write_unpicklable_object>

    def test_cache_write_unpicklable_object(self):
        fetch_middleware = FetchFromCacheMiddleware(empty_response)
>       fetch_middleware.cache = cache
E       AttributeError: can't set attribute 'cache'

tests/test_djangocache.py:873: AttributeError
=============================== warnings summary ===============================
../../nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-p>
../../nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-p>
../../nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-p>
../../nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-p>
../../nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-p>
../../nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-p>
../../nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-p>
../../nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-p>
  /nix/store/5iacqddfwif3ww9gxf82ccl2yhj2jxn1-python3.10-Django-4.1/lib/python3.10/site-pack>
    warnings.warn(USE_L10N_DEPRECATED_MSG, RemovedInDjango50Warning)

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
=========================== short test summary info ============================
FAILED tests/test_djangocache.py::DiskCacheTests::test_cache_write_unpicklable_object
================== 1 failed, 236 passed, 8 warnings in 18.88s ==================

I didn't find any corresponding breaking changes in djangos changelog

Maybe you have an idea?

I don't think it's a DiskCache incompatibility. It's more likely the test changed in 4.1 in a Django incompatible way.

Here's the test in DiskCache from Django 3.2 LTS: https://github.com/grantjenks/python-diskcache/blob/v5.4.0/tests/test_djangocache.py#L871

And here's the test in Django from 4.1: https://github.com/django/django/blob/stable/4.1.x/tests/cache/tests.py#L1057

Most likely it's just the test that needs updating. I don't see anything in the test that is DiskCache specific.

@grantjenks I also ran into this test failure on diskcache-5.4.0, and updating the test according to the attached patch helped to pass the test. Apart from different whitespace and different quotes, it is identical to the change you suggested above. Please update.

For the most part, I only guarantee compatibility with LTS releases. Django 4.2 will be released in April so should fix it soon. Please open a PR to get it fixed faster.

Fixed in v5.5.1 on PyPI