From d512dfb0a57193565ac8e74c73f5b02edeb68360 Mon Sep 17 00:00:00 2001 From: Trenton H <797416+stumpylog@users.noreply.github.com> Date: Wed, 25 Mar 2026 15:44:14 -0700 Subject: [PATCH] Alright, let's try the LLM solution. I don't see the global state leaking --- .../tests/test_migration_sha256_checksums.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/documents/tests/test_migration_sha256_checksums.py b/src/documents/tests/test_migration_sha256_checksums.py index 010863f50..4a53b724c 100644 --- a/src/documents/tests/test_migration_sha256_checksums.py +++ b/src/documents/tests/test_migration_sha256_checksums.py @@ -4,6 +4,7 @@ import tempfile from pathlib import Path from django.conf import settings +from django.db import connection from django.test import override_settings from documents.tests.utils import TestMigrations @@ -84,6 +85,17 @@ class TestSha256ChecksumDataMigration(TestMigrations): archive_checksum=None, ).pk + def _fixture_teardown(self) -> None: + super()._fixture_teardown() + # Django's SQLite backend returns [] from sequence_reset_sql(), so + # reset_sequences=True flushes rows but never clears sqlite_sequence. + # Explicitly delete the entry so subsequent tests start from pk=1. + if connection.vendor == "sqlite": + with connection.cursor() as cursor: + cursor.execute( + "DELETE FROM sqlite_sequence WHERE name='documents_document'", + ) + def tearDown(self) -> None: super().tearDown() self._settings_override.disable()