2017-11-15 13:03:45 -05:00
|
|
|
import pytest
|
2018-06-16 07:30:15 -04:00
|
|
|
from unittest.mock import patch
|
2017-11-15 13:03:45 -05:00
|
|
|
|
2016-09-25 15:07:42 -04:00
|
|
|
import xonsh.completers.path as xcp
|
|
|
|
|
2017-11-15 13:03:45 -05:00
|
|
|
|
2018-06-16 07:30:15 -04:00
|
|
|
@pytest.fixture(autouse=True)
|
|
|
|
def xonsh_execer_autouse(xonsh_builtins, xonsh_execer):
|
|
|
|
return xonsh_execer
|
|
|
|
|
|
|
|
|
2016-09-25 15:07:42 -04:00
|
|
|
def test_pattern_need_quotes():
|
|
|
|
# just make sure the regex compiles
|
2018-08-30 09:18:49 -05:00
|
|
|
xcp.PATTERN_NEED_QUOTES.match("")
|
2017-11-15 13:03:45 -05:00
|
|
|
|
|
|
|
|
|
|
|
def test_complete_path(xonsh_builtins):
|
2018-09-13 14:03:35 -04:00
|
|
|
xonsh_builtins.__xonsh__.env = {
|
2018-08-30 09:18:49 -05:00
|
|
|
"CASE_SENSITIVE_COMPLETIONS": False,
|
|
|
|
"GLOB_SORTED": True,
|
|
|
|
"SUBSEQUENCE_PATH_COMPLETION": False,
|
|
|
|
"FUZZY_PATH_COMPLETION": False,
|
|
|
|
"SUGGEST_THRESHOLD": 3,
|
|
|
|
"CDPATH": set(),
|
2017-11-15 13:03:45 -05:00
|
|
|
}
|
2018-08-30 09:18:49 -05:00
|
|
|
xcp.complete_path("[1-0.1]", "[1-0.1]", 0, 7, dict())
|
2018-06-16 07:30:15 -04:00
|
|
|
|
|
|
|
|
2018-08-30 09:18:49 -05:00
|
|
|
@patch("xonsh.completers.path._add_cdpaths")
|
2018-06-16 07:30:15 -04:00
|
|
|
def test_cd_path_no_cd(mock_add_cdpaths, xonsh_builtins):
|
2018-09-13 14:03:35 -04:00
|
|
|
xonsh_builtins.__xonsh__.env = {
|
2018-08-30 09:18:49 -05:00
|
|
|
"CASE_SENSITIVE_COMPLETIONS": False,
|
|
|
|
"GLOB_SORTED": True,
|
|
|
|
"SUBSEQUENCE_PATH_COMPLETION": False,
|
|
|
|
"FUZZY_PATH_COMPLETION": False,
|
|
|
|
"SUGGEST_THRESHOLD": 3,
|
|
|
|
"CDPATH": ["/"],
|
2018-06-16 07:30:15 -04:00
|
|
|
}
|
2018-08-30 09:18:49 -05:00
|
|
|
xcp.complete_path("a", "cat a", 4, 5, dict())
|
2018-06-16 07:30:15 -04:00
|
|
|
mock_add_cdpaths.assert_not_called()
|