mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Backported CliRunner fix from e3eb356a
Removed obsolete mix_stderr=False arguments from CliRunner() calls which are not supported in Click 8.3.0.
This commit is contained in:
parent
0e2d9ccd99
commit
ef8e75db78
3 changed files with 11 additions and 8 deletions
|
|
@ -193,7 +193,7 @@ def test_version():
|
|||
|
||||
@pytest.mark.parametrize("invalid_port", ["-1", "0.5", "dog", "65536"])
|
||||
def test_serve_invalid_ports(invalid_port):
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["--port", invalid_port])
|
||||
assert result.exit_code == 2
|
||||
assert "Invalid value for '-p'" in result.stderr
|
||||
|
|
@ -209,7 +209,7 @@ def test_setting():
|
|||
|
||||
|
||||
def test_setting_type_validation():
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["--setting", "default_page_size", "dog"])
|
||||
assert result.exit_code == 2
|
||||
assert '"default_page_size" should be an integer' in result.stderr
|
||||
|
|
@ -239,17 +239,20 @@ def test_setting_default_allow_sql(default_allow_sql):
|
|||
|
||||
def test_config_deprecated():
|
||||
# The --config option should show a deprecation message
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli, ["--config", "allow_download:off", "--get", "/-/settings.json"]
|
||||
)
|
||||
assert result.exit_code == 0
|
||||
assert not json.loads(result.output)["allow_download"]
|
||||
assert "will be deprecated in" in result.stderr
|
||||
# Extract JSON from output (skip the deprecation warning line)
|
||||
output_lines = result.output.strip().split("\n")
|
||||
json_output = "\n".join(line for line in output_lines if line.startswith("{"))
|
||||
assert not json.loads(json_output)["allow_download"]
|
||||
assert "will be deprecated in" in result.output
|
||||
|
||||
|
||||
def test_sql_errors_logged_to_stderr():
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, ["--get", "/_memory.json?sql=select+blah"])
|
||||
assert result.exit_code == 1
|
||||
assert "sql = 'select blah', params = {}: no such column: blah\n" in result.stderr
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ def test_settings(config_dir_client):
|
|||
def test_error_on_config_json(tmp_path_factory):
|
||||
config_dir = tmp_path_factory.mktemp("config-dir")
|
||||
(config_dir / "config.json").write_text(json.dumps(SETTINGS), "utf-8")
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(cli, [str(config_dir), "--get", "/-/settings.json"])
|
||||
assert result.exit_code == 1
|
||||
assert "config.json should be renamed to settings.json" in result.stderr
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ def test_crossdb_warning_if_too_many_databases(tmp_path_factory):
|
|||
conn = sqlite3.connect(path)
|
||||
conn.execute("vacuum")
|
||||
dbs.append(path)
|
||||
runner = CliRunner(mix_stderr=False)
|
||||
runner = CliRunner()
|
||||
result = runner.invoke(
|
||||
cli,
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue