summaryrefslogtreecommitdiffstats
path: root/test/t/test_env.py
blob: 7608a4b418485055d58f31e3c5687ee700e1fd00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import pytest

from conftest import assert_complete


class TestEnv:
    @pytest.mark.complete("env --", require_longopt=True)
    def test_1(self, completion):
        assert completion

    @pytest.mark.complete("env __unknown_variable__=")
    def test_unknown_variable_falls_back_to_filedir(self, completion):
        assert "shared/" in completion

    @pytest.mark.complete("env LANG=", xfail="! locale -a &>/dev/null")
    def test_lang_envvar(self, completion):
        assert any(x == "C" or x.startswith("C.") for x in completion)

    @pytest.mark.parametrize(
        "opts",
        [
            "",
            "foo=bar",
            "--debug",
            "--debug foo=bar",
            "-",
            "- foo=bar",
        ],
    )
    def test_command(self, bash, opts):
        completion = assert_complete(bash, "env %s s" % opts)
        assert completion == "h" or "sh" in completion

    @pytest.mark.parametrize(
        "opts",
        [
            "foo=bar --non-existent",
            "- --non-existent",
            "-- --non-existent",
        ],
    )
    def test_option_like_command(self, bash, opts):
        completion = assert_complete(bash, "env %s s" % opts)
        assert not (completion == "h" or "sh" in completion)