Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Bump Authlib to fix reference cycle (#17547)

Filip Owczarekecca6f88c52d
diff --git a/poetry.lock b/poetry.lock
index 0546939e8a..9ab7d912b0 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -119,15 +119,15 @@ tests-mypy = ["mypy (>=1.11.1) ; platform_python_implementation == \"CPython\" a
[[package]]
name = "authlib"
-version = "1.4.0"
+version = "1.5.1"
description = "The ultimate Python library in building OAuth and OpenID Connect servers and clients."
optional = false
python-versions = ">=3.9"
groups = ["main"]
markers = "platform_python_implementation == \"PyPy\""
files = [
- {file = "Authlib-1.4.0-py2.py3-none-any.whl", hash = "sha256:4bb20b978c8b636222b549317c1815e1fe62234fc1c5efe8855d84aebf3a74e3"},
- {file = "authlib-1.4.0.tar.gz", hash = "sha256:1c1e6608b5ed3624aeeee136ca7f8c120d6f51f731aa152b153d54741840e1f2"},
+ {file = "authlib-1.5.1-py2.py3-none-any.whl", hash = "sha256:8408861cbd9b4ea2ff759b00b6f02fd7d81ac5a56d0b2b22c08606c6049aae11"},
+ {file = "authlib-1.5.1.tar.gz", hash = "sha256:5cbc85ecb0667312c1cdc2f9095680bb735883b123fb509fde1e65b1c5df972e"},
]
[package.dependencies]
@@ -6051,4 +6051,4 @@ type = ["pytest-mypy"]
[metadata]
lock-version = "2.1"
python-versions = "~3.12"
-content-hash = "ffc5b2e8399044a51e1b2ed166c25ba3eb87bfe715070be3f12b70e82cb63ab9"
+content-hash = "ed08f72eba1fa28a9002de21546df3bc8b19cc877019bfdb85263caa568cae28"
diff --git a/pyproject.toml b/pyproject.toml
index f31df706a0..da4b474771 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -59,7 +59,7 @@ package-mode = false
python = "~3.12"
Adyen = "^4.0.0"
asgiref = "^3.7.2"
- Authlib = "^1.3.1"
+ Authlib = "^1.4.1"
authorizenet = "^1.1.5"
azure-common = "^1.1.28"
azure-storage-blob = "^12.23.1"
diff --git a/saleor/graphql/core/tests/garbage_collection/__init__.py b/saleor/graphql/core/tests/garbage_collection/__init__.py
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/saleor/graphql/core/tests/garbage_collection/test_oauth2.py b/saleor/graphql/core/tests/garbage_collection/test_oauth2.py
new file mode 100644
index 0000000000..d267fac92d
--- /dev/null
+++ b/saleor/graphql/core/tests/garbage_collection/test_oauth2.py
@@ -0,0 +1,36 @@
+import gc
+
+import pytest
+from authlib.integrations.requests_client import OAuth2Session
+
+from .utils import (
+ clean_up_after_garbage_collection_test,
+ disable_gc_for_garbage_collection_test,
+)
+
+
+# Group all tests that require garbage collection so that they do not run concurrently.
+# This is necessary to ensure that tests don't interfere with each other.
+# Without grouping we could receive false positive results.
[email protected]_group(name="garbage_collection")
+def test_OAuth2Session_remove_all_reference_cycles():
+ try:
+ # given
+ # Disable automatic garbage collection and set debugging flag.
+ disable_gc_for_garbage_collection_test()
+
+ # when
+ # Create 0Auth2Session object
+ OAuth2Session()
+ # Enforce garbage collection to populate the garbage list for inspection.
+ gc.collect()
+
+ # then
+ # Ensure that the garbage list is empty. The garbage list is only valid
+ # until the next collection cycle so we can only make assertions about it
+ # before re-enabling automatic collection.
+ assert gc.garbage == []
+ # Restore garbage collection settings to their original state. This should always be run to avoid interfering
+ # with other tests to ensure that code should be executed in the `finally' block.
+ finally:
+ clean_up_after_garbage_collection_test()
diff --git a/saleor/graphql/core/tests/garbage_collection/utils.py b/saleor/graphql/core/tests/garbage_collection/utils.py
new file mode 100644
index 0000000000..e0f24b8a88
--- /dev/null
+++ b/saleor/graphql/core/tests/garbage_collection/utils.py
@@ -0,0 +1,27 @@
+import gc
+
+
+def disable_gc_for_garbage_collection_test():
+ # Disable automatic garbage collection. To have control over when
+ # garbage collection is performed. This is necessary to ensure that another
+ # that thread doesn't accidentally trigger it by simply executing code.
+ gc.disable()
+
+ # Delete the garbage list(`gc.garbage`) to ensure that other tests don't
+ # interfere with this test.
+ gc.collect()
+
+ # Set the garbage collection debugging flag to store all unreachable
+ # objects in `gc.garbage`. This is necessary to ensure that the
+ # garbage list is empty after execute test code. Otherwise, the test
+ # will always pass. The garbage list isn't automatically populated
+ # because it costs extra CPU cycles
+ gc.set_debug(gc.DEBUG_SAVEALL)
+
+
+def clean_up_after_garbage_collection_test():
+ # Clean up the garbage collection settings. Re-enable automatic garbage
+ # collection. This step is mandatory to avoid running other tests without
+ # automatic garbage collection.
+ gc.set_debug(0)
+ gc.enable()