mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-16 05:24:26 +02:00
Extracted detect_column_types as suggest_column_types, refs #81
This commit is contained in:
parent
f7289174e6
commit
5ecf3ffdea
3 changed files with 47 additions and 27 deletions
19
tests/test_suggest_column_types.py
Normal file
19
tests/test_suggest_column_types.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
import pytest
|
||||
from sqlite_utils.utils import suggest_column_types
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"records,types",
|
||||
[
|
||||
([{"a": 1}], {"a": int}),
|
||||
([{"a": "baz"}], {"a": str}),
|
||||
([{"a": 1.2}], {"a": float}),
|
||||
([{"a": [1]}], {"a": str}),
|
||||
([{"a": (1,)}], {"a": str}),
|
||||
([{"a": {"b": 1}}], {"a": str}),
|
||||
([{"a": 1}, {"a": 1.1}], {"a": float}),
|
||||
([{"a": b"b"}], {"a": bytes}),
|
||||
],
|
||||
)
|
||||
def test_suggest_column_types(records, types):
|
||||
assert types == suggest_column_types(records)
|
||||
Loading…
Add table
Add a link
Reference in a new issue