From 658185d297a307d0b9d43fd83019a5acab032f18 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 5 Jul 2026 15:46:16 -0700 Subject: [PATCH] Fix compound foreign key test failure against sqlean test_create_table_compound_foreign_key_enforced caught the stdlib sqlite3.IntegrityError, but sqlean's IntegrityError is not a subclass of it. Import sqlite3 from sqlite_utils.utils like the other test modules, so the right exception is used whichever backend is installed. Co-Authored-By: Claude Fable 5 --- tests/test_foreign_keys.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_foreign_keys.py b/tests/test_foreign_keys.py index b22638a..7fcd788 100644 --- a/tests/test_foreign_keys.py +++ b/tests/test_foreign_keys.py @@ -3,6 +3,7 @@ import pytest from sqlite_utils import Database from sqlite_utils.db import AlterError, ForeignKey +from sqlite_utils.utils import sqlite3 COMPOUND_SCHEMA = """ CREATE TABLE departments ( @@ -185,8 +186,6 @@ def test_create_table_compound_foreign_key_enforced(departments_db): departments_db["courses"].insert( {"course_code": "CS101", "campus_name": "Berkeley", "dept_code": "CS"} ) - import sqlite3 - with pytest.raises(sqlite3.IntegrityError): departments_db.execute( "insert into courses (course_code, campus_name, dept_code) "