mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-04 08:24:40 +01:00
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:
parent
8c6fc1332d
commit
839e0ad1a6
3 changed files with 65 additions and 2 deletions
24
news/fix_pip_completer.rst
Normal file
24
news/fix_pip_completer.rst
Normal 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>
|
39
tests/completers/test_pip_completer.py
Normal file
39
tests/completers/test_pip_completer.py
Normal 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
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue