summaryrefslogtreecommitdiffstats
path: root/test/t/unit/test_unit_unlocal.py
blob: be5ec5663b8811f4f47a52c5d176240de6bbf6d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import pytest

from conftest import assert_bash_exec


@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+(VAR=|declare -f foo)")
class TestUnlocal:
    def test_1(self, bash):
        cmd = (
            "foo() { "
            "local VAR=inner; "
            "_comp_unlocal VAR; "
            "echo $VAR; "
            "}; "
            "VAR=outer; foo; "
        )
        res = assert_bash_exec(bash, cmd, want_output=True).strip()
        assert res == "outer"