Skip to content

Commit

Permalink
test: don't sort expected completion lists under the hood
Browse files Browse the repository at this point in the history
We need to match the order in which bash lists completions, which may
not be a straightforward one. For example, it seems to add slashes after
sorting dir completions without changing the sort order. For example
"foo" sorts before "foo-bar", but "foo/" after "foo-bar/", but the order
of completion output is "foo/" followed by "foo-bar/". Test cases should
sort their lists explicitly where appropriate.
  • Loading branch information
scop committed Jul 6, 2019
1 parent faacf36 commit 1e3d504
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion test/t/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ def __eq__(self, expected: Union[str, Iterable[str]]) -> bool:
Defining __eq__ this way is quite ugly, but facilitates concise
testing code.
"""
expiter = [expected] if isinstance(expected, str) else sorted(expected)
expiter = [expected] if isinstance(expected, str) else expected
if self._items is not None:
return self._items == expiter
return bool(
Expand Down
4 changes: 2 additions & 2 deletions test/t/test_kdvi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
class TestKdvi:
@pytest.mark.complete("kdvi ", cwd="kdvi")
def test_1(self, completion):
assert (
completion == "foo/ .dvi .DVI .dvi.bz2 .DVI.bz2 .dvi.gz "
assert completion == sorted(
"foo/ .dvi .DVI .dvi.bz2 .DVI.bz2 .dvi.gz "
".DVI.gz .dvi.Z .DVI.Z".split()
)
2 changes: 1 addition & 1 deletion test/t/test_kpdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
class TestKpdf:
@pytest.mark.complete("kpdf ", cwd="kpdf")
def test_1(self, completion):
assert completion == "foo/ .eps .ps .EPS .PS .pdf .PDF".split()
assert completion == sorted("foo/ .eps .ps .EPS .PS .pdf .PDF".split())

0 comments on commit 1e3d504

Please sign in to comment.