|
| 1 | +import pytest |
| 2 | + |
| 3 | +from conftest import assert_bash_exec, assert_complete |
| 4 | + |
| 5 | + |
| 6 | +@pytest.mark.bashcomp(cmd=None, ignore_env=r"^\+COMPREPLY=|^[-+]_comp_xspecs=") |
| 7 | +class TestUnitFiledirXspec: |
| 8 | + @pytest.fixture(scope="class") |
| 9 | + def functions(self, request, bash): |
| 10 | + assert_bash_exec( |
| 11 | + bash, |
| 12 | + "_comp_xspecs[xspec1]='!*.txt'; " |
| 13 | + "_comp_xspecs[xspec2]=; " |
| 14 | + "_comp_xspecs[xspec4]='*.txt'; " |
| 15 | + "complete -F _filedir_xspec xspec{1..4}", |
| 16 | + ) |
| 17 | + |
| 18 | + def test_1(self, bash, functions): |
| 19 | + """Test the pattern for an extension""" |
| 20 | + completion = assert_complete(bash, "xspec1 ", cwd="_filedir_xspec") |
| 21 | + assert completion == sorted("a.txt b.TXT".split()) |
| 22 | + |
| 23 | + def test_2(self, bash, functions): |
| 24 | + """Test an empty _comp_xspecs entry""" |
| 25 | + completion = assert_complete(bash, "xspec2 ", cwd="_filedir_xspec") |
| 26 | + assert completion == sorted("a.txt b.TXT c.dat d.bin".split()) |
| 27 | + |
| 28 | + def test_3(self, bash, functions): |
| 29 | + """Test an unset _comp_xspecs entry""" |
| 30 | + completion = assert_complete(bash, "xspec3 ", cwd="_filedir_xspec") |
| 31 | + assert completion == sorted("a.txt b.TXT c.dat d.bin".split()) |
| 32 | + |
| 33 | + def test_4(self, bash, functions): |
| 34 | + """Test an exclusion pattern""" |
| 35 | + completion = assert_complete(bash, "xspec4 ", cwd="_filedir_xspec") |
| 36 | + assert completion == sorted("c.dat d.bin".split()) |
0 commit comments