Repository: django-compressor/django-compressor (language: python)

Issue:
Python 3.11 test failure
I'm seeing `OfflineCompressTestCaseWithLazyStringAlikeUrls` test failures under Python 3.11. Bisecting the Python 3.11 branch showed that the https://github.com/python/cpython/commit/76cd81d60310d65d01f9d7b48a8985d8ab89c8b4 commit introduced the issue.

I tried commenting out the `@functools.lru_cache(typed=True)` line from the `urlsplit` function in the Python 3.11 branch, and that seemed to fix the test. Does there need to be a `clear_cache()` call, or some other way to deal with the `urlsplit` cache in Python 3.11?


Discussion / hints:

Fix patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 124760f0..49a4223b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -33,6 +33,8 @@ jobs:
             toxenv: py39-4.1.X
           - python: "3.10"
             toxenv: py310-4.1.X
+          - python: "3.11"
+            toxenv: py311-4.1.X
 
     runs-on: ubuntu-latest
     steps:
diff --git a/setup.py b/setup.py
index 35e301bd..4be74675 100644
--- a/setup.py
+++ b/setup.py
@@ -156,6 +156,7 @@ def find_package_data(
         "Programming Language :: Python :: 3.8",
         "Programming Language :: Python :: 3.9",
         "Programming Language :: Python :: 3.10",
+        "Programming Language :: Python :: 3.11",
         "Topic :: Internet :: WWW/HTTP",
     ],
     zip_safe=False,
diff --git a/tox.ini b/tox.ini
index 9e871cc2..da0a67eb 100644
--- a/tox.ini
+++ b/tox.ini
@@ -2,12 +2,13 @@
 envlist =
     {py38,py39,py310}-3.2.X
     {py38,py39,py310}-4.0.X
-    {py38,py39,py310}-4.1.X
+    {py38,py39,py310,py311}-4.1.X
 [testenv]
 basepython =
     py38: python3.8
     py39: python3.9
     py310: python3.10
+    py311: python3.11
 usedevelop = true
 setenv =
     CPPFLAGS=-O0


Test patch:
diff --git a/compressor/tests/test_offline.py b/compressor/tests/test_offline.py
index 1af5cb2f..c208048e 100644
--- a/compressor/tests/test_offline.py
+++ b/compressor/tests/test_offline.py
@@ -55,6 +55,9 @@ def __str__(self):
     def __unicode__(self):
         return str(self)
 
+    def __hash__(self):
+        return str.__hash__(str(self))
+
     def split(self, *args, **kwargs):
         """
         Override ``.split()`` method to make it work with ``{% static %}``.