Skip to content

Commit 56dd67a

Browse files
committed
maintain sort order check post Pygments adjustment
When adjusting the test suite for Pygments versions, reverse the sense of the version check, so that the order of returned completions can still be tested.
1 parent 9f0ca3b commit 56dd67a

4 files changed

Lines changed: 32 additions & 19 deletions

File tree

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Upcoming (TBD)
44
Bug Fixes
55
---------
66
* Respect `history_file` setting in the `[main]` section of `~/.myclirc`.
7+
* Adapt test suite to pygments v2.20.0.
78

89

910
1.72.1 (2026/05/11)
@@ -12,7 +13,6 @@ Bug Fixes
1213
Bug Fixes
1314
---------
1415
* Update `sqlglot` to v30.7.0 to fix has_bit_strings error.
15-
* Adapt test suite to pygments 2.20.0
1616

1717

1818
1.72.0 (2026/05/08)

test/pytests/test_naive_completion.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from prompt_toolkit.document import Document
55
import pytest
66

7-
from test.utils import pygments_at_least
7+
from test.utils import pygments_below
88

99

1010
@pytest.fixture
@@ -43,6 +43,7 @@ def test_function_name_completion(completer, complete_event):
4343
'MAKEDATE',
4444
'MAKETIME',
4545
'MAKE_SET',
46+
'MANUAL',
4647
'MASTER',
4748
'MASTER_AUTO_POSITION',
4849
'MASTER_BIND',
@@ -82,10 +83,9 @@ def test_function_name_completion(completer, complete_event):
8283
'MAX_USER_CONNECTIONS',
8384
]
8485

85-
if pygments_at_least("2.20"):
86-
expected.extend([
87-
'MANUAL',
88-
])
86+
if pygments_below("2.20"):
87+
expected.remove('MASTER')
88+
8989
assert sorted(x.text for x in result) == sorted(expected)
9090

9191

test/pytests/test_smart_completion_public_schema_only.py

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import pytest
99

1010
import mycli.packages.special.main as special
11-
from test.utils import pygments_at_least
11+
from test.utils import pygments_below
1212

1313
metadata = {
1414
"users": ["id", "email", "first_name", "last_name"],
@@ -862,6 +862,7 @@ def test_backticked_column_completion_two_character(completer, complete_event):
862862
Completion(text='`fixed`', start_position=-2),
863863
Completion(text='`float`', start_position=-2),
864864
Completion(text='`fetch`', start_position=-2),
865+
Completion(text='`files`', start_position=-2),
865866
Completion(text='`first`', start_position=-2),
866867
Completion(text='`flush`', start_position=-2),
867868
Completion(text='`force`', start_position=-2),
@@ -879,14 +880,19 @@ def test_backticked_column_completion_two_character(completer, complete_event):
879880
Completion(text='`fulltext`', start_position=-2),
880881
Completion(text='`function`', start_position=-2),
881882
Completion(text='`from_days`', start_position=-2),
883+
Completion(text='`file_name`', start_position=-2),
882884
Completion(text='`following`', start_position=-2),
883885
Completion(text='`first_name`', start_position=-2),
884886
Completion(text='`found_rows`', start_position=-2),
885887
Completion(text='`find_in_set`', start_position=-2),
886888
Completion(text='`first_value`', start_position=-2),
887889
Completion(text='`from_base64`', start_position=-2),
890+
Completion(text='`from_vector`', start_position=-2),
891+
Completion(text='`file_format`', start_position=-2),
892+
Completion(text='`file_prefix`', start_position=-2),
888893
Completion(text='`foreign key`', start_position=-2),
889894
Completion(text='`format_bytes`', start_position=-2),
895+
Completion(text='`file_pattern`', start_position=-2),
890896
Completion(text='`from_unixtime`', start_position=-2),
891897
Completion(text='`file_block_size`', start_position=-2),
892898
Completion(text='`format_pico_time`', start_position=-2),
@@ -913,17 +919,18 @@ def test_backticked_column_completion_two_character(completer, complete_event):
913919
Completion(text='`references`', start_position=-2),
914920
]
915921

916-
if pygments_at_least("2.20"):
917-
expected.extend([
922+
if pygments_below("2.20"):
923+
for newer in [
918924
Completion(text='`file_format`', start_position=-2),
919925
Completion(text='`file_name`', start_position=-2),
920926
Completion(text='`file_pattern`', start_position=-2),
921927
Completion(text='`file_prefix`', start_position=-2),
922928
Completion(text='`files`', start_position=-2),
923929
Completion(text='`from_vector`', start_position=-2),
924-
])
930+
]:
931+
expected.remove(newer)
925932

926-
assert sorted((x.text, x.start_position) for x in result) == sorted((x.text, x.start_position) for x in expected)
933+
assert result == expected
927934

928935

929936
def test_backticked_column_completion_three_character(completer, complete_event):
@@ -935,13 +942,18 @@ def test_backticked_column_completion_three_character(completer, complete_event)
935942
Completion(text='`file`', start_position=-3),
936943
Completion(text='`field`', start_position=-3),
937944
Completion(text='`fixed`', start_position=-3),
945+
Completion(text='`files`', start_position=-3),
938946
Completion(text='`first`', start_position=-3),
939947
Completion(text='`fields`', start_position=-3),
940948
Completion(text='`filter`', start_position=-3),
941949
Completion(text='`finish`', start_position=-3),
950+
Completion(text='`file_name`', start_position=-3),
942951
Completion(text='`first_name`', start_position=-3),
943952
Completion(text='`find_in_set`', start_position=-3),
944953
Completion(text='`first_value`', start_position=-3),
954+
Completion(text='`file_format`', start_position=-3),
955+
Completion(text='`file_prefix`', start_position=-3),
956+
Completion(text='`file_pattern`', start_position=-3),
945957
Completion(text='`file_block_size`', start_position=-3),
946958
Completion(text='`definer`', start_position=-3),
947959
Completion(text='`definition`', start_position=-3),
@@ -955,16 +967,17 @@ def test_backticked_column_completion_three_character(completer, complete_event)
955967
Completion(text='`foreign key`', start_position=-3),
956968
]
957969

958-
if pygments_at_least("2.20"):
959-
expected.extend([
960-
Completion(text='`file_format`', start_position=-3),
970+
if pygments_below("2.20"):
971+
for newer in [
972+
Completion(text='`files`', start_position=-3),
961973
Completion(text='`file_name`', start_position=-3),
974+
Completion(text='`file_format`', start_position=-3),
962975
Completion(text='`file_pattern`', start_position=-3),
963976
Completion(text='`file_prefix`', start_position=-3),
964-
Completion(text='`files`', start_position=-3),
965-
])
977+
]:
978+
expected.remove(newer)
966979

967-
assert sorted((x.text, x.start_position) for x in result) == sorted((x.text, x.start_position) for x in expected)
980+
assert result == expected
968981

969982

970983
def test_backticked_column_completion_four_character(completer, complete_event):

test/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@
3939
PYGMENTS_VERSION = Version(pygments.__version__)
4040

4141

42-
def pygments_at_least(version: str) -> bool:
43-
return PYGMENTS_VERSION >= Version(version)
42+
def pygments_below(version: str) -> bool:
43+
return PYGMENTS_VERSION < Version(version)
4444

4545

4646
class DummyLogger:

0 commit comments

Comments
 (0)