simonw / sqlite-utils

Python CLI utility and library for manipulating SQLite databases
https://sqlite-utils.datasette.io
Apache License 2.0
1.63k stars 111 forks source link

Fix tests for Python 3.11 #502

Closed simonw closed 1 year ago

simonw commented 1 year ago

The way errors are represented has changed: https://github.com/simonw/sqlite-utils/actions/runs/3323588047/jobs/5494127154

_________________________ test_query_invalid_function __________________________

db_path = '/tmp/pytest-of-runner/pytest-0/test_query_invalid_function0/test.db'

    def test_query_invalid_function(db_path):
        result = CliRunner().invoke(
            cli.cli, [db_path, "select bad()", "--functions", "def invalid_python"]
        )
        assert result.exit_code == 1
>       assert (
            result.output.strip()
            == "Error: Error in functions definition: invalid syntax (<string>, line 1)"
        )
E       AssertionError: assert 'Error: Error...ing>, line 1)' == 'Error: Error...ing>, line 1)'
E         - Error: Error in functions definition: invalid syntax (<string>, line 1)
E         ?                                       ^^^^^^  ^^^^^^
E         + Error: Error in functions definition: expected '(' (<string>, line 1)
E         ?                                       ^^^^^^^  ^^^
simonw commented 1 year ago

Replicated locally using a fresh virtual environment with Python 3.11 and:

 pytest -k test_query_invalid_function