Extract shared Python test utilities into tests/helpers.py

Deduplicates exec(), vec0_shadow_table_contents(), _f32(), _i64(), and
_int8() helpers that were copied across six test files.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Alex Garcia 2026-03-02 20:05:21 -08:00
parent 206fbc2bdd
commit 9a6bf96b92
7 changed files with 56 additions and 192 deletions

View file

@ -1,31 +1,7 @@
import sqlite3
import struct
from collections import OrderedDict
import pytest
def _f32(list):
return struct.pack("%sf" % len(list), *list)
def exec(db, sql, parameters=[]):
try:
rows = db.execute(sql, parameters).fetchall()
except (sqlite3.OperationalError, sqlite3.DatabaseError) as e:
return {
"error": e.__class__.__name__,
"message": str(e),
}
a = []
for row in rows:
o = OrderedDict()
for k in row.keys():
o[k] = row[k]
a.append(o)
result = OrderedDict()
result["sql"] = sql
result["rows"] = a
return result
from helpers import _f32, exec
def test_insert_creates_chunks_and_vectors(db, snapshot):