mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
Merge branch 'vc_tests' into vcfix
This commit is contained in:
commit
cf2e9f7ca5
8 changed files with 51 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
|||
import glob
|
||||
import builtins
|
||||
import glob
|
||||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -15,6 +16,13 @@ from xonsh.platform import ON_WINDOWS
|
|||
from tools import DummyShell, sp, DummyCommandsCache, DummyEnv, DummyHistory
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def source_path():
|
||||
"""Get the xonsh source path."""
|
||||
pwd = os.path.dirname(__file__)
|
||||
return os.path.dirname(pwd)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def xonsh_execer(monkeypatch):
|
||||
"""Initiate the Execer with a mocked nop `load_builtins`"""
|
||||
|
|
1
tests/git-test-repo
Submodule
1
tests/git-test-repo
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 8f5e6cab3efbe2341d7e27efd5b739efed3ae93f
|
BIN
tests/hg-test-repo/.hg/00changelog.i
Normal file
BIN
tests/hg-test-repo/.hg/00changelog.i
Normal file
Binary file not shown.
5
tests/hg-test-repo/.hg/requires
Normal file
5
tests/hg-test-repo/.hg/requires
Normal file
|
@ -0,0 +1,5 @@
|
|||
dotencode
|
||||
fncache
|
||||
generaldelta
|
||||
revlogv1
|
||||
store
|
|
@ -1,9 +1,14 @@
|
|||
import os
|
||||
import subprocess as sp
|
||||
from unittest.mock import Mock
|
||||
|
||||
import pytest
|
||||
|
||||
from xonsh.environ import Env
|
||||
from xonsh.prompt.base import PromptFormatter
|
||||
from xonsh.prompt import vc
|
||||
|
||||
from tools import skip_if_py34, DummyEnv
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
@ -76,7 +81,9 @@ def test_format_prompt_with_invalid_func(formatter, xonsh_builtins):
|
|||
assert isinstance(formatter(p), str)
|
||||
|
||||
|
||||
def test_format_prompt_with_func_that_raises(formatter, capsys, xonsh_builtins):
|
||||
def test_format_prompt_with_func_that_raises(formatter,
|
||||
capsys,
|
||||
xonsh_builtins):
|
||||
xonsh_builtins.__xonsh_env__ = Env()
|
||||
template = 'tt {zerodiv} tt'
|
||||
exp = 'tt (ERROR:zerodiv) tt'
|
||||
|
@ -106,3 +113,28 @@ def test_promptformatter_clears_cache(formatter):
|
|||
formatter(template, fields)
|
||||
|
||||
assert spam.call_count == 2
|
||||
|
||||
|
||||
@pytest.mark.parametrize('repo', ['hg', 'git'])
|
||||
def test_test_repos(source_path, repo):
|
||||
test_repo = os.path.join(source_path, 'tests', '{}-test-repo'.format(repo))
|
||||
assert os.path.isdir(test_repo)
|
||||
assert os.path.isdir(os.path.join(test_repo, '.{}'.format(repo)))
|
||||
|
||||
|
||||
@skip_if_py34
|
||||
@pytest.mark.parametrize('cmd, exp', [
|
||||
('git', 'master'),
|
||||
('hg', 'default'),
|
||||
])
|
||||
def test_vc_get_branch(cmd, exp, source_path, xonsh_builtins):
|
||||
test_repo = '{}-test-repo'.format(cmd)
|
||||
test_repo_path = os.path.join(source_path, 'tests', test_repo)
|
||||
os.chdir(test_repo_path)
|
||||
xonsh_builtins.__xonsh_env__ = Env(VC_BRANCH_TIMEOUT=1)
|
||||
# get corresponding function from vc module
|
||||
if cmd == 'hg':
|
||||
obs = vc.get_hg_branch()
|
||||
else:
|
||||
obs = vc.get_git_branch()
|
||||
assert obs == exp
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import pytest
|
||||
|
||||
try:
|
||||
import prompt_toolkit
|
||||
import prompt_toolkit # NOQA
|
||||
except ImportError:
|
||||
pytest.skip(msg='prompt_toolkit is not available')
|
||||
pytest.mark.skip(msg='prompt_toolkit is not available')
|
||||
|
||||
from xonsh.ptk.history import PromptToolkitHistory
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ from xonsh.prompt.cwd import (
|
|||
)
|
||||
from xonsh.prompt.job import _current_job
|
||||
from xonsh.prompt.env import (env_name, vte_new_tab_cwd)
|
||||
from xonsh.prompt.vc_branch import (
|
||||
from xonsh.prompt.vc import (
|
||||
current_branch, branch_color, branch_bg_color
|
||||
)
|
||||
from xonsh.prompt.gitstatus import gitstatus_prompt
|
||||
|
|
Loading…
Add table
Reference in a new issue