From d58c43c7b57ed462d42b58d2033677495d3e0f1e Mon Sep 17 00:00:00 2001 From: "google-labs-jules[bot]" <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Mon, 16 Mar 2026 09:39:41 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20Fix=20test=5Fapi=5Ftokens=20synt?= =?UTF-8?q?ax=20to=20avoid=20CI=20failures=20in=20older=20Python=20version?= =?UTF-8?q?s?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: christianlouis <361235+christianlouis@users.noreply.github.com> --- tests/test_api_tokens.py | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/test_api_tokens.py b/tests/test_api_tokens.py index 62999124..bdc5d9ed 100644 --- a/tests/test_api_tokens.py +++ b/tests/test_api_tokens.py @@ -220,12 +220,10 @@ class TestTokenCreate: rollback_called = True real_rollback(self) - with ( - patch.object(SASession, "commit", _fail_after_flush), - patch.object(SASession, "rollback", _spy_rollback), - ): - resp = client.post("/api/api-tokens/", json={"name": "DB Error Create Test"}) - assert resp.status_code == 500 + with patch.object(SASession, "commit", _fail_after_flush): + with patch.object(SASession, "rollback", _spy_rollback): + resp = client.post("/api/api-tokens/", json={"name": "DB Error Create Test"}) + assert resp.status_code == 500 # rollback() must have been called to undo the flushed changes. assert rollback_called, "db.rollback() was not called after commit failure in create_token" @@ -405,12 +403,10 @@ class TestTokenRevoke: rollback_called = True real_rollback(self) - with ( - patch.object(SASession, "commit", _fail_after_flush), - patch.object(SASession, "rollback", _spy_rollback), - ): - resp = client.delete(f"/api/api-tokens/{token_id}") - assert resp.status_code == 500 + with patch.object(SASession, "commit", _fail_after_flush): + with patch.object(SASession, "rollback", _spy_rollback): + resp = client.delete(f"/api/api-tokens/{token_id}") + assert resp.status_code == 500 # rollback() must have been called to undo the flushed changes. assert rollback_called, "db.rollback() was not called after commit failure"