From 7d26a3fc6a7d6149877e489e91f5e630688a020d Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Sun, 16 Aug 2026 12:06:19 -0400 Subject: [PATCH] =?UTF-8?q?fix(tests):=20provenance=20itest=20user=20fixtu?= =?UTF-8?q?re=20is=20get-or-create=20=E2=80=94=20the=20lane=20DB=20persist?= =?UTF-8?q?s=20across=20tests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both integration tests built the same username; the second insert died on users_username_key. 19 passed, 1 error on run 3802. Co-Authored-By: Claude Fable 5 --- tests/test_snippet_provenance.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/test_snippet_provenance.py b/tests/test_snippet_provenance.py index ef35941..ac60ac5 100644 --- a/tests/test_snippet_provenance.py +++ b/tests/test_snippet_provenance.py @@ -88,10 +88,21 @@ async def _dispose_engine(): @pytest_asyncio.fixture async def user_id(_dispose_engine): + # Get-or-create: the lane's database persists across tests, so a second + # test re-creating the same username dies on the unique constraint. + from sqlalchemy import select + from scribe.models import async_session from scribe.models.user import User async with async_session() as s: + existing = ( + await s.execute( + select(User).where(User.username == "snippet_prov_itest") + ) + ).scalar_one_or_none() + if existing is not None: + return existing.id user = User(username="snippet_prov_itest") s.add(user) await s.flush()