mirror of
https://github.com/asg017/sqlite-vec.git
synced 2026-04-25 00:36:56 +02:00
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:
parent
206fbc2bdd
commit
9a6bf96b92
7 changed files with 56 additions and 192 deletions
|
|
@ -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):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue