mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 09:24:31 +02:00
Merge 4a4e38d0a2 into a947dc6739
This commit is contained in:
commit
09f7b4d8b4
2 changed files with 12 additions and 1 deletions
|
|
@ -3800,7 +3800,7 @@ def _rows_from_code(code):
|
|||
namespace = {}
|
||||
try:
|
||||
exec(code, namespace)
|
||||
except SyntaxError as ex:
|
||||
except Exception as ex:
|
||||
raise click.ClickException("Error in --code: {}".format(ex))
|
||||
rows = namespace.get("rows")
|
||||
if callable(rows):
|
||||
|
|
|
|||
|
|
@ -880,6 +880,17 @@ def test_insert_code_syntax_error(tmpdir):
|
|||
assert "Error in --code" in result.output
|
||||
|
||||
|
||||
def test_insert_code_runtime_error(tmpdir):
|
||||
db_path = str(tmpdir / "dogs.db")
|
||||
result = CliRunner().invoke(
|
||||
cli.cli,
|
||||
["insert", db_path, "creatures", "--code", 'raise ValueError("bad data")'],
|
||||
)
|
||||
assert result.exit_code == 1
|
||||
assert "Error in --code" in result.output
|
||||
assert "bad data" in result.output
|
||||
|
||||
|
||||
def test_insert_code_file_not_found(tmpdir):
|
||||
db_path = str(tmpdir / "dogs.db")
|
||||
result = CliRunner().invoke(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue