Exemplo n.º 1
0
class TestArp:
    @pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
    @pytest.mark.complete("arp ")
    def test_1(self, completion):
        assert completion

    @pytest.mark.complete("arp -")
    def test_2(self, completion):
        assert completion
Exemplo n.º 2
0
class TestIfdown:

    @pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
    @pytest.mark.complete("ifdown ")
    def test_1(self, completion):
        assert completion

    @pytest.mark.complete("ifdown bash-completion ")
    def test_2(self, completion):
        assert not completion
Exemplo n.º 3
0
class TestIfup:
    @pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
    @pytest.mark.complete("ifup ")
    def test_1(self, completion):
        assert completion

    @pytest.mark.complete("ifup --", skipif="! ifup --help &>/dev/null")
    def test_2(self, completion):
        assert completion

    @pytest.mark.complete("ifup bash-completion ")
    def test_3(self, completion):
        assert not completion
Exemplo n.º 4
0
class TestUnitIpAddresses:
    @pytest.fixture(scope="class")
    def functions(self, request, bash):
        assert_bash_exec(
            bash, "_ia() { local cur=$(_get_cword);unset COMPREPLY;"
            "_ip_addresses; }")
        assert_bash_exec(bash, "complete -F _ia ia")
        assert_bash_exec(
            bash, "_iaa() { local cur=$(_get_cword);unset COMPREPLY;"
            "_ip_addresses -a; }")
        assert_bash_exec(bash, "complete -F _iaa iaa")
        assert_bash_exec(
            bash, " _ia6() { local cur=$(_get_cword);unset COMPREPLY;"
            "_ip_addresses -6; }")
        assert_bash_exec(bash, "complete -F _ia6 ia6")

    def test_1(self, bash):
        assert_bash_exec(bash, "_ip_addresses")

    @pytest.mark.complete("iaa ")
    def test_2(self, functions, completion):
        """_ip_addresses -a should complete ip addresses."""
        assert completion
        assert all("." in x or ":" in x for x in completion)

    @pytest.mark.complete("ia ")
    def test_3(self, functions, completion):
        """_ip_addresses should complete ipv4 addresses."""
        assert completion
        assert all("." in x for x in completion)

    @pytest.mark.xfail(in_docker(), reason="Probably fails in docker")
    @pytest.mark.complete("ia6 ")
    def test_4(self, functions, completion):
        """_ip_addresses -6 should complete ipv6 addresses."""
        assert completion
        assert all(":" in x for x in completion)
Exemplo n.º 5
0
class TestMake:
    @pytest.mark.complete("make -f Ma", cwd="make")
    def test_1(self, completion):
        assert completion == "Makefile"

    @pytest.mark.complete("make .", cwd="make")
    def test_2(self, bash, completion):
        """Hidden targets."""
        assert completion == ".cache/ .test_passes".split()
        os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))

    @pytest.mark.complete("make .cache/", cwd="make")
    def test_3(self, bash, completion):
        assert completion == "1 2".split()
        os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))

    @pytest.mark.complete("make ", cwd="shared/empty_dir")
    def test_4(self, completion):
        assert not completion

    @pytest.mark.complete("make -j ")
    def test_5(self, completion):
        assert completion

    @pytest.mark.complete("make ", cwd="make")
    def test_6(self, bash, completion):
        assert completion == "all clean extra_makefile install sample".split()
        os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))

    @pytest.mark.xfail(in_docker() and os.environ.get("DIST") == "centos6",
                       reason="Fails for some unknown reason on CentOS 6, "
                       "even though the behavior appears to be correct")
    @pytest.mark.complete("make .cache/.", cwd="make")
    def test_7(self, bash, completion):
        assert completion == ".1 .2".split()
        os.remove("%s/make/%s" % (bash.cwd, "extra_makefile"))
Exemplo n.º 6
0
class TestMan:

    manpath = "$PWD/man"
    assumed_present = "man"

    @pytest.fixture
    def colonpath(self, request, bash):
        try:
            assert_bash_exec(bash, "uname -s 2>&1 | grep -qiF cygwin")
        except AssertionError:
            pass
        else:
            pytest.skip("Cygwin doesn't like paths with colons")
            return
        assert_bash_exec(bash, "mkdir -p $TESTDIR/../tmp/man/man3")
        assert_bash_exec(
            bash, "touch $TESTDIR/../tmp/man/man3/Bash::Completion.3pm.gz")
        request.addfinalizer(
            lambda: assert_bash_exec(bash, "rm -r $TESTDIR/../tmp/man"))

    @pytest.mark.complete("man bash-completion-testcas",
                          env=dict(MANPATH=manpath))
    def test_1(self, completion):
        assert completion == "bash-completion-testcase"

    @pytest.mark.complete("man man1/f", cwd="man", env=dict(MANPATH=manpath))
    def test_2(self, completion):
        assert completion == "man1/foo.1"

    @pytest.mark.complete("man man/", cwd="man", env=dict(MANPATH=manpath))
    def test_3(self, completion):
        assert completion == "man/quux.8"

    @pytest.mark.xfail(in_docker() and os.environ.get("DIST") == "centos6",
                       reason="TODO: Fails in CentOS for some reason, unknown "
                       "how to trigger same behavior as tests show (is "
                       "different and correct when tried manually, but here "
                       "at least in CI completes things it should not with "
                       "this MANPATH setting)")
    @pytest.mark.complete("man %s" % assumed_present, cwd="shared/empty_dir",
                          env=dict(MANPATH=manpath))
    def test_4(self, completion):
        """
        Assumed present should not be completed complete when there's no
        leading/trailing colon in $MANPATH.
        """
        assert not completion

    @pytest.mark.complete("man %s" % assumed_present,
                          cwd="shared/empty_dir",
                          env=dict(MANPATH="%s:" % manpath))
    def test_5(self, completion):
        """Trailing colon appends system man path."""
        assert completion

    @pytest.mark.complete(
        "man bash-completion-testcas", env=dict(MANPATH="%s:" % manpath))
    def test_6(self, completion):
        assert completion == "bash-completion-testcase"

    @pytest.mark.complete("man %s" % assumed_present,
                          cwd="shared/empty_dir",
                          env=dict(MANPATH=":%s" % manpath))
    def test_7(self, completion):
        """Leading colon prepends system man path."""
        assert completion

    @pytest.mark.complete(
        "man bash-completion-testcas", env=dict(MANPATH=":%s" % manpath))
    def test_8(self, completion):
        assert completion == "bash-completion-testcase"

    @pytest.mark.complete("man %s" % assumed_present,
                          cwd="shared/empty_dir",
                          pre_cmds=("shopt -s failglob",))
    def test_9(self, bash, completion):
        assert self.assumed_present in completion
        assert_bash_exec(bash, "shopt -u failglob")

    @pytest.mark.complete("man Bash::C",
                          env=dict(MANPATH="%s:../tmp/man" % manpath))
    def test_10(self, bash, colonpath, completion):
        assert completion == "Bash::Completion"