Skip to content

Commit cf18f4b

Browse files
srdeotarseneiljp
authored andcommitted
refactor: test_boxes: Assert all output strings match required_typeaheads.
This improves diagnosis of which states may be failing in test cases in test_generic_autocomplete_streams. When an assert is in a loop and one fails, others are not tested, which doesn't always present a clear picture of what is wrong. For example, it could be that multiple results are in the wrong order, and the code needs to generate them in a different order to pass the test.
1 parent c9982fd commit cf18f4b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tests/ui_tools/test_boxes.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -938,9 +938,12 @@ def test_generic_autocomplete_streams(
938938
for stream in stream_dict.values()
939939
if stream["name"] in stream_categories.get("muted", set())
940940
)
941-
for state, required_typeahead in state_and_required_typeahead.items():
942-
typeahead_string = write_box.generic_autocomplete(text, state)
943-
assert typeahead_string == required_typeahead
941+
states = state_and_required_typeahead.keys()
942+
required_typeaheads = list(state_and_required_typeahead.values())
943+
typeahead_strings = [
944+
write_box.generic_autocomplete(text, state) for state in states
945+
]
946+
assert typeahead_strings == required_typeaheads
944947

945948
@pytest.mark.parametrize(
946949
"text, state, required_typeahead",

0 commit comments

Comments
 (0)