summaryrefslogtreecommitdiff
path: root/test/t/unit/test_unit_get_cword.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/t/unit/test_unit_get_cword.py')
-rw-r--r--test/t/unit/test_unit_get_cword.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/test/t/unit/test_unit_get_cword.py b/test/t/unit/test_unit_get_cword.py
index 3042dd29..0b56d163 100644
--- a/test/t/unit/test_unit_get_cword.py
+++ b/test/t/unit/test_unit_get_cword.py
@@ -1,17 +1,22 @@
+import pexpect
import pytest
-from conftest import assert_bash_exec, TestUnitBase
+from conftest import PS1, TestUnitBase, assert_bash_exec
@pytest.mark.bashcomp(
- cmd=None, ignore_env=r"^[+-]COMP_(WORDS|CWORD|LINE|POINT)="
+ cmd=None, ignore_env=r"^[+-](COMP_(WORDS|CWORD|LINE|POINT)|_scp_path_esc)="
)
class TestUnitGetCword(TestUnitBase):
def _test(self, *args, **kwargs):
return self._test_unit("_get_cword %s; echo", *args, **kwargs)
def test_1(self, bash):
- assert_bash_exec(bash, "_get_cword >/dev/null")
+ assert_bash_exec(
+ bash,
+ "COMP_WORDS=() COMP_CWORD= COMP_LINE= COMP_POINT= "
+ "_get_cword >/dev/null",
+ )
def test_2(self, bash):
"""a b| should return b"""
@@ -133,3 +138,17 @@ class TestUnitGetCword(TestUnitBase):
"""a 'b&c| should return 'b&c"""
output = self._test(bash, '(a "\'b&c")', 1, "a 'b&c", 6)
assert output == "'b&c"
+
+ @pytest.mark.xfail(reason="TODO: non-ASCII issues with test suite?")
+ def test_24(self, bash):
+ """Index shouldn't drop below 0"""
+ bash.send("scp ääää§ se\t\r\n")
+ got = bash.expect_exact(
+ [
+ "index: substring expression < 0",
+ PS1,
+ pexpect.EOF,
+ pexpect.TIMEOUT,
+ ]
+ )
+ assert got == 1