1import pytest 2 3from conftest import assert_complete, partialize 4 5 6@pytest.mark.bashcomp(pre_cmds=("HOME=$PWD",)) 7class TestXhost: 8 @pytest.mark.parametrize("prefix", ["+", "-", ""]) 9 def test_hosts(self, bash, hosts, prefix): 10 completion = assert_complete(bash, "xhost %s" % prefix) 11 assert completion == ["%s%s" % (prefix, x) for x in hosts] 12 13 @pytest.mark.parametrize("prefix", ["+", "-", ""]) 14 def test_partial_hosts(self, bash, hosts, prefix): 15 first_char, partial_hosts = partialize(bash, hosts) 16 completion = assert_complete(bash, "xhost %s%s" % (prefix, first_char)) 17 if len(completion) == 1: 18 assert completion == partial_hosts[0][1:] 19 else: 20 assert completion == sorted( 21 "%s%s" % (prefix, x) for x in partial_hosts 22 ) 23