From f436a6a666576b5424db83f0bda2451b20f53e7c Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 23 Nov 2025 22:11:26 -0800 Subject: [PATCH] Fix failing tests --- tests/test_cli.py | 35 +++++++++++++++++++++++++++++++---- tests/test_cli_insert.py | 6 +++--- tests/test_sniff.py | 2 +- 3 files changed, 35 insertions(+), 8 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 9f60e8d..b8d61a9 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1907,7 +1907,16 @@ def test_insert_encoding(tmpdir): # Using --encoding=latin-1 should work good_result = CliRunner().invoke( cli.cli, - ["insert", db_path, "places", csv_path, "--encoding", "latin-1", "--csv", "--no-detect-types"], + [ + "insert", + db_path, + "places", + csv_path, + "--encoding", + "latin-1", + "--csv", + "--no-detect-types", + ], catch_exceptions=False, ) assert good_result.exit_code == 0 @@ -2196,7 +2205,7 @@ def test_import_no_headers(tmpdir, args, tsv): csv_file.write("Tracy{sep}Spider{sep}7\n".format(sep=sep)) result = CliRunner().invoke( cli.cli, - ["insert", db_path, "creatures", csv_path] + args, + ["insert", db_path, "creatures", csv_path] + args + ["--no-detect-types"], catch_exceptions=False, ) assert result.exit_code == 0, result.output @@ -2245,7 +2254,16 @@ def test_csv_insert_bom(tmpdir): fp.write(b"\xef\xbb\xbfname,age\nCleo,5") result = CliRunner().invoke( cli.cli, - ["insert", db_path, "broken", bom_csv_path, "--encoding", "utf-8", "--csv", "--no-detect-types"], + [ + "insert", + db_path, + "broken", + bom_csv_path, + "--encoding", + "utf-8", + "--csv", + "--no-detect-types", + ], catch_exceptions=False, ) assert result.exit_code == 0 @@ -2362,7 +2380,16 @@ def test_upsert_no_detect_types(tmpdir): data = "id,name,age,weight\n1,Cleo,6,45.5\n2,Dori,1,3.5" result = CliRunner().invoke( cli.cli, - ["upsert", db_path, "creatures", "-", "--csv", "--pk", "id", "--no-detect-types"], + [ + "upsert", + db_path, + "creatures", + "-", + "--csv", + "--pk", + "id", + "--no-detect-types", + ], catch_exceptions=False, input=data, ) diff --git a/tests/test_cli_insert.py b/tests/test_cli_insert.py index a699c94..9f21b00 100644 --- a/tests/test_cli_insert.py +++ b/tests/test_cli_insert.py @@ -227,7 +227,7 @@ def test_insert_csv_tsv(content, options, db_path, tmpdir): fp.write(content) result = CliRunner().invoke( cli.cli, - ["insert", db_path, "data", file_path] + options, + ["insert", db_path, "data", file_path] + options + ["--no-detect-types"], catch_exceptions=False, ) assert result.exit_code == 0 @@ -236,7 +236,7 @@ def test_insert_csv_tsv(content, options, db_path, tmpdir): @pytest.mark.parametrize("empty_null", (True, False)) def test_insert_csv_empty_null(db_path, empty_null): - options = ["--csv"] + options = ["--csv", "--no-detect-types"] if empty_null: options.append("--empty-null") result = CliRunner().invoke( @@ -430,7 +430,7 @@ def test_insert_text(db_path): "options,input", ( ([], '[{"id": "1", "name": "Bob"}, {"id": "2", "name": "Cat"}]'), - (["--csv"], "id,name\n1,Bob\n2,Cat"), + (["--csv", "--no-detect-types"], "id,name\n1,Bob\n2,Cat"), (["--nl"], '{"id": "1", "name": "Bob"}\n{"id": "2", "name": "Cat"}'), ), ) diff --git a/tests/test_sniff.py b/tests/test_sniff.py index 36cc471..62fac86 100644 --- a/tests/test_sniff.py +++ b/tests/test_sniff.py @@ -12,7 +12,7 @@ def test_sniff(tmpdir, filepath): runner = CliRunner() result = runner.invoke( cli.cli, - ["insert", db_path, "creatures", str(filepath), "--sniff"], + ["insert", db_path, "creatures", str(filepath), "--sniff", "--no-detect-types"], catch_exceptions=False, ) assert result.exit_code == 0, result.stdout