mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 17:34:32 +02:00
Added basic tests using hypothesis, closes #180
This commit is contained in:
parent
47af71f603
commit
0b5edd6469
2 changed files with 44 additions and 1 deletions
2
setup.py
2
setup.py
|
|
@ -25,7 +25,7 @@ setup(
|
|||
install_requires=["click", "click-default-group", "tabulate"],
|
||||
setup_requires=["pytest-runner"],
|
||||
extras_require={
|
||||
"test": ["pytest", "black"],
|
||||
"test": ["pytest", "black", "hypothesis"],
|
||||
"docs": ["sphinx_rtd_theme", "sphinx-autobuild"],
|
||||
},
|
||||
entry_points="""
|
||||
|
|
|
|||
43
tests/test_hypothesis.py
Normal file
43
tests/test_hypothesis.py
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
from hypothesis import given
|
||||
import hypothesis.strategies as st
|
||||
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]
|
||||
Loading…
Add table
Add a link
Reference in a new issue