Scan your whole stack
Are you using fixturify?
Find out what’s in your code.
Scan your apps free in minutes (opens in a new tab)Latest version: v0.1.42
fixturify was last scanned on 27 Nov 2026 at version 0.1.42. Risk score 0 of 100. No malicious behavior was detected.
| Version | Published | Status |
|---|---|---|
| 0.1.42 LATEST | 27 Nov 2026 | No rules fired |
| 0.1.41 | 26 Nov 2026 | No rules fired |
Findings for v0.1.42. The score is a capped sum of the weights of the rules that fired — not CVSS, not exploitability, and not a probability. It is not comparable across packages with different scan coverage.
The score describes 0.1.42; other versions have their own rules, not their own score.
The publisher’s own README, as collected from the registry.
A collection of Python testing utilities for SQL, HTTP mocking, JSON fixtures, assertions, and object mapping.
pip install fixturify
Decorator for executing SQL files before and/or after tests.
from fixturify import sql, Phase, SqlTestConfig
@sql(path="./setup.sql")
def test_something():
# SQL executed before test
pass
| Parameter | Type | Default | Description |
|---|---|---|---|
path |
str |
required | Path to SQL file (relative to test file) |
phase |
Phase |
Phase.BEFORE |
When to execute |
config |
SqlTestConfig \| None |
None |
Database config (or use fixture) |
@sql(path="./setup.sql", phase=Phase.BEFORE)
@sql(path="./cleanup.sql", phase=Phase.AFTER)
def test_with_cleanup():
# setup.sql executed before test
# cleanup.sql executed after test (even if test fails)
pass
Phase.BEFORE (default) - execute SQL before testPhase.AFTER - execute SQL after test, runs in finally block (always executes, even on failure)On a fixture, use a yield fixture for cleanup — its Phase.AFTER scripts run at teardown, after the test
(also when the test fails). On a fixture that returns, they run right after the fixture function, i.e. before
the test; fixturify warns about this. A yield fixture takes the config from its own arguments, so request your
config fixture (or request) there:
@pytest.fixture
@sql(path="./cleanup.sql", phase=Phase.AFTER)
def clean_tables(sql_config):
yield
# conftest.py
import pytest
from fixturify import SqlTestConfig
@pytest.fixture
def sql_config() -> SqlTestConfig:
return SqlTestConfig(
driver="psycopg2",
host="localhost",
port=5432,
database="testdb",
user="postgres",
password="postgres",
)
Fixture is auto-discovered - no need to pass it to the decorator.
Important: The return type annotation
-> SqlTestConfigis required for auto-discovery. The discovery mechanism matches fixtures by their return type annotation, so without it the fixture will not be found.
config = SqlTestConfig(
driver="psycopg2",
host="localhost",
database="testdb",
user="postgres",
password="postgres",
)
@sql(path="./setup.sql", config=config)
def test_something():
pass
| Field | Type | Required | Description |
|---|---|---|---|
driver |
str |
yes | Database driver name |
host |
str |
yes | Database host |
database |
str |
yes | Database name |
user |
str |
yes | Username |
password |
str |
yes | Password |
port |
int \| None |
no | Port (uses driver default if omitted) |
Driver name is normalized: leading + and whitespace are stripped (e.g. "postgresql+psycopg2" becomes "psycopg2").
| Driver | Database | Type | Default port |
|---|---|---|---|
psycopg2 |
PostgreSQL | sync | 5432 |
psycopg |
PostgreSQL | async | 5432 |
asyncpg |
PostgreSQL | async | 5432 |
mysql.connector |
MySQL | sync | 3306 |
aiomysql |
MySQL | async | 3306 |
sqlite3 |
SQLite | sync | - |
aiosqlite |
SQLite | async | - |
Decorator automatically handles async test functions. Sync drivers in async tests run via thread pool executor. Async drivers in sync tests use a persistent background event loop (see Connection caching). If an async test is cancelled while a script runs, fixturify waits for that script to finish, so it can't commit after the test is gone; remaining Phase.AFTER scripts still run.
@sql(path="./setup.sql")
async def test_async():
# Works with asyncpg, aiomysql, aiosqlite
pass
Decorators execute top-to-bottom for BEFORE, bottom-to-top for AFTER:
@sql(path="./first.sql") # 1st executed
@sql(path="./second.sql") # 2nd executed
@sql(path="./cleanup.sql", phase=Phase.AFTER) # executed after test
def test_order():
pass
Connections are cached and reused between tests based on driver/host/database/user/port, and closed when the test session ends.
asyncpg and psycopg run their queries on fixturify's background loop, on a connection that is handed from
one test to the next, so tests don't reconnect every time (with asyncpg that saved ~50 ms per test). Each
test still starts with a clean session: settings (SET …) and temporary tables of an earlier test are reset.
Tests running at the same time get separate connections. Event loops that live longer (class, module,
package or session scope) keep a connection of their own on that loop, exactly as before. aiomysql and
aiosqlite always use a connection per event loop (an aiosqlite ":memory:" database belongs to its loop).psycopg works on Windows' default event loop (ProactorEventLoop), which psycopg itself can't use: its
queries run on fixturify's background loop.fork get their own connections; the parent's connections are left untouched.Paths are resolved relative to the test file:
tests/
test_users.py <- @sql(path="./fixtures/setup.sql")
fixtures/
setup.sql <- this file will be used
Fluent API for database state assertions in tests.
from fixturify import sql, SqlAssert, SqlTestConfig
@sql(path="./setup.sql")
def test_user_creation(sql_assert: SqlAssert):
create_user(name="John", email="john@example.com")
sql_assert.table("users").where(name="John").exists()
sql_assert fixture requires a sql_config fixture returning SqlTestConfig:
# conftest.py
import pytest
from fixturify import SqlTestConfig
@pytest.fixture
def sql_config() -> SqlTestConfig:
return SqlTestConfig(
driver="psycopg2",
host="localhost",
port=5432,
database="testdb",
user="postgres",
password="postgres",
)
The sql_assert fixture is automatically available when sql_config is defined.
sql_assert.table("users") # TableAssert - fluent builder for table queries
sql_assert.raw(sql, params=None) # RawQueryAssert - custom SQL queries
Add equality conditions combined with AND:
sql_assert.table("users").where(name="John", role="admin").exists()
# WHERE name = 'John' AND role = 'admin'
Multiple where() calls are combined with AND:
sql_assert.table("users")\
.where(role="admin")\
.where(is_active=True)\
.exists()
# WHERE role = 'admin' AND is_active = True
sql_assert.table("users").where_null("deleted_at").count(5)
# WHERE deleted_at IS NULL
where(deleted_at=None) does the same (= NULL would never match in SQL).
sql_assert.table("users").where_not_null("email").exists()
# WHERE email IS NOT NULL
Pass a list as a value to generate an IN (...) clause:
sql_assert.table("users").where(id=[1, 2, 3]).exists()
# WHERE id IN (1, 2, 3)
sql_assert.table("users").where(id=[1, 2, 3], role="admin").fetch_all()
# WHERE id IN (1, 2, 3) AND role = 'admin'
Empty lists raise ValueError (SQL IN () is invalid). None in a list also matches NULL:
where(id=[1, None]) → WHERE (id IN (1) OR id IS NULL).
first_user = sql_assert.table("users").order_by("created_at").fetch_one()
latest_user = sql_assert.table("users").order_by("created_at", desc=True).fetch_one()
top_5 = sql_assert.table("users").order_by("score", desc=True).limit(5).fetch_all()
Assert at least one row matches:
sql_assert.table("users").where(name="John").exists()
Assert no rows match:
sql_assert.table("users").where(name="Deleted").not_exists()
sql_assert.table("users").count(5) # exactly 5
sql_assert.table("users").count_gt(0) # more than 0
sql_assert.table("users").count_gte(1) # at least 1
sql_assert.table("users").count_lt(100) # less than 100
sql_assert.table("users").count_lte(10) # at most 10
Assert first matching row has specified values:
sql_assert.table("users").where(id=1).has(
name="John",
email="john@example.com",
role="admin"
)
Assert ALL matching rows have specified values:
sql_assert.table("users").where(role="admin").has_all(is_active=True)
Assert ANY matching row has specified values:
sql_assert.table("users").has_any(email="john@example.com")
Fetch first matching row as dict:
row = sql_assert.table("users").where(id=1).fetch_one()
# {'id': 1, 'name': 'John', 'email': 'john@example.com'}
Fetch and map to object using ObjectMapper:
from dataclasses import dataclass
@dataclass
class User:
id: int
name: str
email: str
user = sql_assert.table("users").where(id=1).fetch_one(User)
assert isinstance(user, User)
Works with dataclasses, Pydantic models, SQLAlchemy models, SQLModel, and plain objects. Maps only flat column data from the table row - relationships are not loaded (use raw() with JOIN for that).
Fetch all matching rows as list of dicts:
rows = sql_assert.table("users").fetch_all()
Fetch all and map to objects:
users = sql_assert.table("users").fetch_all(User)
assert all(isinstance(u, User) for u in users)
Fetch single value from first matching row:
email = sql_assert.table("users").where(id=1).fetch_value("email")
# "john@example.com"
Returns None if no rows match or column not found.
All query-building methods return new instances (immutable), enabling safe chaining:
sql_assert.table("users")\
.where(role="admin")\
.where(is_active=True)\
.where_not_null("email")\
.order_by("name")\
.limit(10)\
.fetch_all(User)
Chaining creates independent queries:
base = sql_assert.table("users")
admins = base.where(role="admin")
active_admins = admins.where(is_active=True)
# Each query is independent
base.count(100) # all users
admins.count(10) # only admins
active_admins.count(8) # only active admins
For complex queries, use raw():
# Custom query with parameters
result = sql_assert.raw(
"SELECT COUNT(*) as cnt FROM users WHERE created_at > %s",
["2024-01-01"]
).fetch_one()
assert result["cnt"] > 0
# Existence check with JOIN
sql_assert.raw(
"SELECT 1 FROM users u JOIN orders o ON u.id = o.user_id WHERE o.total > %s",
[1000]
).exists()
# Non-existence check
sql_assert.raw(
"SELECT 1 FROM users WHERE email LIKE %s",
["%@banned.com"]
).not_exists()
Parameter placeholders are automatically converted per driver (%s for psycopg2/mysql, $1 for asyncpg, ? for sqlite3).
For async tests, use methods with a prefix:
@sql(path="./setup.sql")
async def test_async(sql_assert: SqlAssert):
await sql_assert.table("users").where(name="John").aexists()
await sql_assert.table("users").where(name="Deleted").anot_exists()
await sql_assert.table("users").acount(5)
await sql_assert.table("users").acount_gt(0)
await sql_assert.table("users").acount_gte(1)
await sql_assert.table("users").acount_lt(100)
await sql_assert.table("users").acount_lte(10)
await sql_assert.table("users").where(id=1).ahas(name="John")
await sql_assert.table("users").where(role="admin").ahas_all(is_active=True)
await sql_assert.table("users").ahas_any(email="john@example.com")
user = await sql_assert.table("users").where(id=1).afetch_one(User)
users = await sql_assert.table("users").afetch_all(User)
email = await sql_assert.table("users").where(id=1).afetch_value("email")
| Sync | Async |
|---|---|
exists() |
aexists() |
not_exists() |
anot_exists() |
count(n) |
acount(n) |
count_gt(n) |
acount_gt(n) |
count_gte(n) |
acount_gte(n) |
count_lt(n) |
acount_lt(n) |
count_lte(n) |
acount_lte(n) |
has(**fields) |
ahas(**fields) |
has_all(**fields) |
ahas_all(**fields) |
has_any(**fields) |
ahas_any(**fields) |
fetch_one() |
afetch_one() |
fetch_all() |
afetch_all() |
fetch_value(col) |
afetch_value(col) |
fetch_one(TargetClass) and fetch_all(TargetClass) map only flat column data from the queried table. Relationships are not loaded. For related data, use manual queries or raw() with JOIN:
# Manual queries
user = sql_assert.table("users").where(id=1).fetch_one()
orders = sql_assert.table("orders").where(user_id=user["id"]).fetch_all()
# Using raw() with JOIN
result = sql_assert.raw("""
SELECT u.id, u.name, COUNT(o.id) as order_count
FROM users u
LEFT JOIN orders o ON u.id = o.user_id
WHERE u.id = %s
GROUP BY u.id, u.name
""", [1]).fetch_one()
Clear assertion errors with context:
AssertionError: Expected at least 1 row in 'users' where name='John', found 0
AssertionError: Expected 5 rows in 'orders' where status='pending', found 3
AssertionError: Row in 'users' doesn't match expected values:
email: expected 'john@example.com', got 'jane@example.com'
role: expected 'admin', got 'user'
Find threats in your stack.
OX Radar can check high-priority threats, like critical package CVEs, against your context.
Each incident is marked Detected or Not Detected with a remediation plan and proof all tracked in the Response Center.
The probe returned only these fields for this server — auth requirement, protocol and tool list weren’t observed, so they’re not shown (never guessed).
The publisher’s own links, as the registry reports them. These are not sources for the assessment on this page.