From bd0dfb88fdf5714833466787fd73edaff9740a73 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Mar 2021 20:03:25 +0100 Subject: Merging upstream version 1.6.0. Signed-off-by: Daniel Baumann --- tests/liteclirc | 1 + tests/test_completion_engine.py | 4 +++- tests/test_smart_completion_public_schema_only.py | 20 +++++++++++--------- tests/test_sqlexecute.py | 19 ++++++++++++++----- 4 files changed, 29 insertions(+), 15 deletions(-) (limited to 'tests') diff --git a/tests/liteclirc b/tests/liteclirc index e31942f..979b409 100644 --- a/tests/liteclirc +++ b/tests/liteclirc @@ -54,6 +54,7 @@ wider_completion_menu = False # litecli prompt # \D - The full current date # \d - Database name +# \f - File basename of the "main" database # \m - Minutes of the current time # \n - Newline # \P - AM/PM diff --git a/tests/test_completion_engine.py b/tests/test_completion_engine.py index 84d5536..760f275 100644 --- a/tests/test_completion_engine.py +++ b/tests/test_completion_engine.py @@ -36,7 +36,9 @@ def test_order_by_suggests_cols_with_qualified_table_scope(): "SELECT * FROM sch.tabl ORDER BY ", "SELECT * FROM sch.tabl ORDER BY " ) assert sorted_dicts(suggestions) == sorted_dicts( - [{"type": "column", "tables": [("sch", "tabl", None)]},] + [ + {"type": "column", "tables": [("sch", "tabl", None)]}, + ] ) diff --git a/tests/test_smart_completion_public_schema_only.py b/tests/test_smart_completion_public_schema_only.py index ea5c580..e532118 100644 --- a/tests/test_smart_completion_public_schema_only.py +++ b/tests/test_smart_completion_public_schema_only.py @@ -367,15 +367,17 @@ def test_auto_escaped_col_names(completer, complete_event): Document(text=text, cursor_position=position), complete_event ) ) - assert result == [ - Completion(text="*", start_position=0), - Completion(text="`ABC`", start_position=0), - Completion(text="`insert`", start_position=0), - Completion(text="id", start_position=0), - ] + list(map(Completion, completer.functions)) + [ - Completion(text="`select`", start_position=0) - ] + list( - map(Completion, sorted(completer.keywords)) + assert ( + result + == [ + Completion(text="*", start_position=0), + Completion(text="`ABC`", start_position=0), + Completion(text="`insert`", start_position=0), + Completion(text="id", start_position=0), + ] + + list(map(Completion, completer.functions)) + + [Completion(text="`select`", start_position=0)] + + list(map(Completion, sorted(completer.keywords))) ) diff --git a/tests/test_sqlexecute.py b/tests/test_sqlexecute.py index 2dde4d4..029c64b 100644 --- a/tests/test_sqlexecute.py +++ b/tests/test_sqlexecute.py @@ -101,6 +101,17 @@ def test_unicode_support_in_output(executor): assert_result_equal(results, headers=["t"], rows=[(u"é",)]) +@dbtest +def test_invalid_unicode_values_dont_choke(executor): + run(executor, "create table unicodechars(t text)") + # \xc3 is not a valid utf-8 char. But we can insert it into the database + # which can break querying if not handled correctly. + run(executor, u"insert into unicodechars (t) values (cast(x'c3' as text))") + + results = run(executor, u"select * from unicodechars") + assert_result_equal(results, headers=["t"], rows=[("\\xc3",)]) + + @dbtest def test_multiple_queries_same_line(executor): results = run(executor, "select 'foo'; select 'bar'") @@ -186,6 +197,7 @@ def test_bind_parameterized_favorite_query(executor): with pytest.raises(ProgrammingError): results = run(executor, "\\f+ q_param 1 2") + @dbtest def test_verbose_feature_of_favorite_query(executor): set_expanded_output(False) @@ -198,11 +210,7 @@ def test_verbose_feature_of_favorite_query(executor): results = run(executor, "\\f sh_param 1") assert_result_equal( - results, - title=None, - headers=["a", "id"], - rows=[("abc", 1)], - auto_status=False, + results, title=None, headers=["a", "id"], rows=[("abc", 1)], auto_status=False, ) results = run(executor, "\\f+ sh_param 1") @@ -214,6 +222,7 @@ def test_verbose_feature_of_favorite_query(executor): auto_status=False, ) + @dbtest def test_shell_parameterized_favorite_query(executor): set_expanded_output(False) -- cgit v1.2.3