sqlite-utils/tests/test_hypothesis.py
Simon Willison 69a1c0d960
Fixes for Ruff>=0.16.0 (#814)
* Automated upgrades by Ruff

    uvx --with 'ruff>=0.16.0' ruff check . --fix --unsafe-fixes

* Fix remaining Ruff errors with GPT-5.6 Sol high

https://gist.github.com/simonw/6da7906a9fea6e90da131c21a9055199

* Fix flake E501 long lines
* New Protocol for migrations to make ty happy
2026-07-25 14:53:12 -07:00

45 lines
1 KiB
Python

import hypothesis.strategies as st
from hypothesis import given
import sqlite_utils
# SQLite integers are -(2^63) to 2^63 - 1
@given(st.integers(-9223372036854775808, 9223372036854775807))
def test_roundtrip_integers(integer):
db = sqlite_utils.Database(memory=True)
row = {
"integer": integer,
}
db["test"].insert(row)
assert list(db["test"].rows) == [row]
@given(st.text())
def test_roundtrip_text(text):
db = sqlite_utils.Database(memory=True)
row = {
"text": text,
}
db["test"].insert(row)
assert list(db["test"].rows) == [row]
@given(st.binary(max_size=1024 * 1024))
def test_roundtrip_binary(binary):
db = sqlite_utils.Database(memory=True)
row = {
"binary": binary,
}
db["test"].insert(row)
assert list(db["test"].rows) == [row]
@given(st.floats(allow_nan=False))
def test_roundtrip_floats(floats):
db = sqlite_utils.Database(memory=True)
row = {
"floats": floats,
}
db["test"].insert(row)
assert list(db["test"].rows) == [row]