Fix pip completer misfires on bagpipes and similar

Requires a word-ending before `pip`, also adding in support for `xpip`
This commit is contained in:
Gil Forsyth 2019-05-30 15:25:16 -04:00
parent 8c6fc1332d
commit 839e0ad1a6
Failed to generate hash of commit
3 changed files with 65 additions and 2 deletions

View file

@ -0,0 +1,24 @@
**Added:**
* <news item>
**Changed:**
* <news item>
**Deprecated:**
* <news item>
**Removed:**
* <news item>
**Fixed:**
* ``pip`` completer no longer fires when ``pip`` happens to appear within a word
like ``bagpipes``
**Security:**
* <news item>

View file

@ -0,0 +1,39 @@
import pytest
from xonsh.completers.pip import PIP_RE, PIP_LIST_RE
@pytest.mark.parametrize(
"line", ["pip", "xpip search", "$(pip", "![pip", "$[pip", "!(xpip"]
)
def test_pip_re(line):
assert PIP_RE.search(line)
@pytest.mark.parametrize(
"line",
[
"pip show",
"xpip uninstall",
"$(pip show",
"![pip uninstall",
"$[pip show",
"!(xpip uninstall",
],
)
def test_pip_list_re(line):
assert PIP_LIST_RE.search(line)
@pytest.mark.parametrize(
"line",
[
"bagpipes show",
"toxbagpip uninstall",
"$(tompippery show",
"![thewholepipandpaboodle uninstall",
"$[littlebopip show",
"!(boxpip uninstall",
],
)
def test_pip_list_re(line):
assert PIP_RE.search(line) is None

View file

@ -9,12 +9,12 @@ import xonsh.lazyasd as xl
@xl.lazyobject
def PIP_RE():
return re.compile(r"pip(?:\d|\.)*")
return re.compile(r"\bx?pip(?:\d|\.)*")
@xl.lazyobject
def PIP_LIST_RE():
return re.compile(r"pip(?:\d|\.)* (?:uninstall|show)")
return re.compile(r"\bx?pip(?:\d|\.)* (?:uninstall|show)")
@xl.lazyobject