diff options
Diffstat (limited to 'test/t/test_finger.py')
-rw-r--r-- | test/t/test_finger.py | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/test/t/test_finger.py b/test/t/test_finger.py index 92c983fa..d765fdd7 100644 --- a/test/t/test_finger.py +++ b/test/t/test_finger.py @@ -1,16 +1,12 @@ import pytest -from conftest import assert_bash_exec +from conftest import assert_complete, partialize class TestFinger: @pytest.fixture(scope="class") - def users_at(self, bash): - return sorted( - assert_bash_exec( - bash, "compgen -A user -S @", want_output=True - ).split() - ) + def users_at(self, bash, output_sort_uniq): + return output_sort_uniq("compgen -u -S @") @pytest.mark.complete("finger ") def test_1(self, bash, completion, users_at): @@ -21,5 +17,17 @@ class TestFinger: if not any(x.startswith("r") for x in users_at): pytest.skip("No users starting with r") assert completion - assert all(x.startswith("r") for x in completion) + idx = 1 if len(completion) == 1 else 0 + assert completion == sorted( + x[idx:] for x in users_at if x.startswith("r") + ) assert not completion.endswith(" ") + + def test_partial_hostname(self, bash, known_hosts): + first_char, partial_hosts = partialize(bash, known_hosts) + user = "test" + completion = assert_complete(bash, "finger %s@%s" % (user, first_char)) + if len(completion) == 1: + assert completion == partial_hosts[0][1:] + else: + assert completion == ["%s@%s" % (user, x) for x in partial_hosts] |