mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-13 03:54:23 +02:00
Format with Black, remove unused imports, fix implicitly concatenated string
This commit is contained in:
parent
15f15933b1
commit
9c9fdc3790
11 changed files with 95 additions and 112 deletions
|
|
@ -845,14 +845,14 @@ def test_query_json_binary(db_path):
|
|||
"data": {
|
||||
"$base64": True,
|
||||
"encoded": (
|
||||
"eJzt0c1xAyEMBeC7q1ABHleR3HxNAQrIjmb4M0gelx+RTY7p4N2WBYT0vmufUknH"
|
||||
"8kq5lz5pqRFXsTOl3pYkE/NJnHXoStruJEVjc0mOCyTqq/ZMJnXEZW1Js2ZvRm5U+"
|
||||
"DPKk9hRWqjyvTFx0YfzhT6MpGmN2lR1fzxjyfVMD9dFrS+bnkleMpMam/ZGXgrX1I"
|
||||
"/K+5Au3S/9lNQRh0k4Gq/RUz8GiKfsQm+7JLsJ6fTo5JhVG00ZU76kZZkxePx49uI"
|
||||
"jnpNoJyYlWUsoaSl/CcVATje/Kxu13RANnrHweaH3V5Jh4jvGyKCnxJLiXPKhmW3f"
|
||||
"iCnG7Jql7RR3UvFo8jJ4z039dtOkTFmWzL1be9lt8A5II471m6vXy+l0BR/4wAc+8"
|
||||
"IEPfOADH/jABz7wgQ984AMf+MAHPvCBD3zgAx/4wAc+8IEPfOADH/jABz7wgQ984A"
|
||||
"Mf+MAHPvCBD3zgAx/4wAc+8IEPfOADH/jABz7wgQ984PuP7xubBoN9"
|
||||
"eJzt0c1xAyEMBeC7q1ABHleR3HxNAQrIjmb4M0gelx+RTY7p4N2WBYT0vmufUknH"
|
||||
"8kq5lz5pqRFXsTOl3pYkE/NJnHXoStruJEVjc0mOCyTqq/ZMJnXEZW1Js2ZvRm5U+"
|
||||
"DPKk9hRWqjyvTFx0YfzhT6MpGmN2lR1fzxjyfVMD9dFrS+bnkleMpMam/ZGXgrX1I"
|
||||
"/K+5Au3S/9lNQRh0k4Gq/RUz8GiKfsQm+7JLsJ6fTo5JhVG00ZU76kZZkxePx49uI"
|
||||
"jnpNoJyYlWUsoaSl/CcVATje/Kxu13RANnrHweaH3V5Jh4jvGyKCnxJLiXPKhmW3f"
|
||||
"iCnG7Jql7RR3UvFo8jJ4z039dtOkTFmWzL1be9lt8A5II471m6vXy+l0BR/4wAc+8"
|
||||
"IEPfOADH/jABz7wgQ984AMf+MAHPvCBD3zgAx/4wAc+8IEPfOADH/jABz7wgQ984A"
|
||||
"Mf+MAHPvCBD3zgAx/4wAc+8IEPfOADH/jABz7wgQ984PuP7xubBoN9"
|
||||
),
|
||||
},
|
||||
}
|
||||
|
|
@ -1171,12 +1171,12 @@ def test_upsert_alter(db_path, tmpdir):
|
|||
# Not null:
|
||||
(
|
||||
["name", "text", "--not-null", "name"],
|
||||
("CREATE TABLE [t] (\n" " [name] TEXT NOT NULL\n" ")"),
|
||||
("CREATE TABLE [t] (\n [name] TEXT NOT NULL\n)"),
|
||||
),
|
||||
# Default:
|
||||
(
|
||||
["age", "integer", "--default", "age", "3"],
|
||||
("CREATE TABLE [t] (\n" " [age] INTEGER DEFAULT '3'\n" ")"),
|
||||
("CREATE TABLE [t] (\n [age] INTEGER DEFAULT '3'\n)"),
|
||||
),
|
||||
# Compound primary key
|
||||
(
|
||||
|
|
@ -2052,7 +2052,7 @@ def test_triggers(tmpdir, extra_args, expected):
|
|||
),
|
||||
(
|
||||
["dogs"],
|
||||
("CREATE TABLE [dogs] (\n" " [id] INTEGER,\n" " [name] TEXT\n" ")\n"),
|
||||
("CREATE TABLE [dogs] (\n [id] INTEGER,\n [name] TEXT\n)\n"),
|
||||
),
|
||||
(
|
||||
["chickens", "dogs"],
|
||||
|
|
@ -2328,7 +2328,7 @@ def test_rename_table(tmpdir):
|
|||
)
|
||||
assert result_error.exit_code == 1
|
||||
assert result_error.output == (
|
||||
'Error: Table "missing" could not be renamed. ' "no such table: missing\n"
|
||||
'Error: Table "missing" could not be renamed. no such table: missing\n'
|
||||
)
|
||||
# And check --ignore works
|
||||
result_error2 = CliRunner().invoke(
|
||||
|
|
|
|||
|
|
@ -140,8 +140,7 @@ def test_insert_multiple_with_compound_primary_key(db_path, tmpdir):
|
|||
def test_insert_not_null_default(db_path, tmpdir):
|
||||
json_path = str(tmpdir / "dogs.json")
|
||||
dogs = [
|
||||
{"id": i, "name": f"Cleo {i}", "age": i + 3, "score": 10}
|
||||
for i in range(1, 21)
|
||||
{"id": i, "name": f"Cleo {i}", "age": i + 3, "score": 10} for i in range(1, 21)
|
||||
]
|
||||
with open(json_path, "w") as fp:
|
||||
fp.write(json.dumps(dogs))
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ def test_memory_json_nl(tmpdir, use_stdin):
|
|||
@pytest.mark.parametrize("use_stdin", (True, False))
|
||||
def test_memory_csv_encoding(tmpdir, use_stdin):
|
||||
latin1_csv = (
|
||||
b"date,name,latitude,longitude\n" b"2020-03-04,S\xe3o Paulo,-23.561,-46.645\n"
|
||||
b"date,name,latitude,longitude\n2020-03-04,S\xe3o Paulo,-23.561,-46.645\n"
|
||||
)
|
||||
input = None
|
||||
if use_stdin:
|
||||
|
|
|
|||
|
|
@ -710,10 +710,7 @@ def test_columns_not_in_first_record_should_not_cause_batch_to_be_too_large(fres
|
|||
records = [
|
||||
{"c0": "first record"}, # one column in first record -> batch size = 999
|
||||
# fill out the batch with 99 records with enough columns to exceed THRESHOLD
|
||||
*[
|
||||
{f"c{i}": j for i in range(extra_columns)}
|
||||
for j in range(batch_size - 1)
|
||||
],
|
||||
*[{f"c{i}": j for i in range(extra_columns)} for j in range(batch_size - 1)],
|
||||
]
|
||||
try:
|
||||
fresh_db["too_many_columns"].insert_all(
|
||||
|
|
@ -810,7 +807,7 @@ def test_create_index_desc(fresh_db):
|
|||
"select sql from sqlite_master where name='idx_dogs_age_name'"
|
||||
).fetchone()[0]
|
||||
assert sql == (
|
||||
"CREATE INDEX [idx_dogs_age_name]\n" " ON [dogs] ([age] desc, [name])"
|
||||
"CREATE INDEX [idx_dogs_age_name]\n ON [dogs] ([age] desc, [name])"
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -889,9 +886,7 @@ def test_insert_memoryview(fresh_db):
|
|||
|
||||
|
||||
def test_insert_thousands_using_generator(fresh_db):
|
||||
fresh_db["test"].insert_all(
|
||||
{"i": i, "word": f"word_{i}"} for i in range(10000)
|
||||
)
|
||||
fresh_db["test"].insert_all({"i": i, "word": f"word_{i}"} for i in range(10000))
|
||||
assert [{"name": "i", "type": "INTEGER"}, {"name": "word", "type": "TEXT"}] == [
|
||||
{"name": col.name, "type": col.type} for col in fresh_db["test"].columns
|
||||
]
|
||||
|
|
@ -1228,7 +1223,7 @@ def test_create_replace(fresh_db):
|
|||
fresh_db["t"].create({"id": int})
|
||||
# This should not
|
||||
fresh_db["t"].create({"name": str}, replace=True)
|
||||
assert fresh_db["t"].schema == ("CREATE TABLE [t] (\n" " [name] TEXT\n" ")")
|
||||
assert fresh_db["t"].schema == ("CREATE TABLE [t] (\n [name] TEXT\n)")
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
|
|
@ -1352,7 +1347,7 @@ def test_insert_upsert_strict(fresh_db, method_name, strict):
|
|||
def test_create_table_strict(fresh_db, strict):
|
||||
table = fresh_db.create_table("t", {"id": int, "f": float}, strict=strict)
|
||||
assert table.strict == strict or not fresh_db.supports_strict
|
||||
expected_schema = "CREATE TABLE [t] (\n" " [id] INTEGER,\n" " [f] FLOAT\n" ")"
|
||||
expected_schema = "CREATE TABLE [t] (\n [id] INTEGER,\n [f] FLOAT\n)"
|
||||
if strict and not fresh_db.supports_strict:
|
||||
return
|
||||
if strict:
|
||||
|
|
|
|||
|
|
@ -31,8 +31,7 @@ def test_extract_single_column(fresh_db, table, fk_column):
|
|||
+ ")"
|
||||
)
|
||||
assert fresh_db[expected_table].schema == (
|
||||
f"CREATE TABLE [{expected_table}] (\n"
|
||||
+ " [id] INTEGER PRIMARY KEY,\n"
|
||||
f"CREATE TABLE [{expected_table}] (\n [id] INTEGER PRIMARY KEY,\n"
|
||||
" [species] TEXT\n"
|
||||
")"
|
||||
)
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ def test_extracts(fresh_db, kwargs, expected_table, use_table_factory):
|
|||
{"id": 2, "species_id": "Oak"},
|
||||
{"id": 3, "species_id": "Palm"},
|
||||
],
|
||||
**insert_kwargs
|
||||
**insert_kwargs,
|
||||
)
|
||||
# Should now have two tables: Trees and Species
|
||||
assert {expected_table, "Trees"} == set(fresh_db.table_names())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue