From 8f5aa9d73df9701a77c0b6f272439f4a4fc76da1 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Tue, 15 Nov 2016 01:01:34 -0500 Subject: [PATCH 1/9] initial bashisms, super broken --- xonsh/base_shell.py | 19 +++++++++++++++++-- xonsh/shell.py | 2 +- xontrib/bashisms.py | 6 ++++++ 3 files changed, 24 insertions(+), 3 deletions(-) create mode 100644 xontrib/bashisms.py diff --git a/xonsh/base_shell.py b/xonsh/base_shell.py index c6905cd0d..112459d38 100644 --- a/xonsh/base_shell.py +++ b/xonsh/base_shell.py @@ -276,7 +276,6 @@ class BaseShell(object): src, code = self.push(line) if code is None: return - events.on_precommand.fire(src) env = builtins.__xonsh_env__ hist = builtins.__xonsh_history__ # pylint: disable=no-member ts1 = None @@ -353,7 +352,23 @@ class BaseShell(object): self.buffer.append(line) if self.need_more_lines: return None, code + i = 0 + lst = '' src = ''.join(self.buffer) + while src != lst: + lst = src + srcs = events.on_precommand.fire(src) + for s in srcs: + if s != lst: + src = s + break + i += 1 + if i == 1000: + print_exception('Modifcations to source input took more than ' + '1000 iterations to converge.') + return self._compile(src) + + def _compile(self, src): _cache = should_use_cache(self.execer, 'single') if _cache: codefname = code_cache_name(src) @@ -374,7 +389,7 @@ class BaseShell(object): partial_string_info = check_for_partial_string(src) in_partial_string = (partial_string_info[0] is not None and partial_string_info[1] is None) - if ((line == '\n' and not in_partial_string)): + if line == '\n' and not in_partial_string: self.reset_buffer() print_exception() return src, None diff --git a/xonsh/shell.py b/xonsh/shell.py index 095160c39..9f7e74b4b 100644 --- a/xonsh/shell.py +++ b/xonsh/shell.py @@ -15,7 +15,7 @@ from xonsh.events import events events.doc('on_precommand', """ -on_precommand(cmd: str) -> None +on_precommand(cmd: str) -> str Fires just before a command is executed. """) diff --git a/xontrib/bashisms.py b/xontrib/bashisms.py new file mode 100644 index 000000000..5e8f8a47a --- /dev/null +++ b/xontrib/bashisms.py @@ -0,0 +1,6 @@ +"""Bash-like interface extensions for xonsh.""" + +@events.on_precommand +def bash_preproc(cmd): + print("OMG!") + return cmd.replace('!!', __xonsh_history__.inps[-1].strip()) From d0ac0c2efc2947e9c92fed7bb5aad4bb5d4989fc Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Sun, 20 Nov 2016 17:32:53 -0500 Subject: [PATCH 2/9] some cleanup --- xonsh/base_shell.py | 33 ++++++++++++++++++++++++++------- xontrib/bashisms.py | 1 - 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/xonsh/base_shell.py b/xonsh/base_shell.py index 112459d38..0b228434d 100644 --- a/xonsh/base_shell.py +++ b/xonsh/base_shell.py @@ -4,6 +4,7 @@ import io import os import sys import time +import difflib import builtins from xonsh.tools import (XonshError, print_exception, DefaultNotGiven, @@ -348,13 +349,20 @@ class BaseShell(object): """Pushes a line onto the buffer and compiles the code in a way that enables multiline input. """ - code = None self.buffer.append(line) if self.need_more_lines: - return None, code + return None, None + src = self.obtain_source() + return self.compile(src) + + def obtain_source(self): + """Gets the source code from the current buffer and any precommand + event handlers that may be active. + """ i = 0 + limit = sys.getrecursionlimit() lst = '' - src = ''.join(self.buffer) + src = raw = ''.join(self.buffer) while src != lst: lst = src srcs = events.on_precommand.fire(src) @@ -363,12 +371,23 @@ class BaseShell(object): src = s break i += 1 - if i == 1000: + if i == limit: print_exception('Modifcations to source input took more than ' - '1000 iterations to converge.') - return self._compile(src) + 'the recurssion limit number of interations to ' + 'converge.') + if builtins.__xonsh_env__.get('XONSH_DEBUG') and src != raw: + sys.stderr.writelines(difflib.unified_diff( + raw.splitlines(keepends=True), + src.splitlines(keepends=True), + fromfile='before precommand event', + tofile='after precommand event', + )) + return src - def _compile(self, src): + def compile(self, src): + """Compiles source code and returns the (possibly modified) source and + a valid code object. + """ _cache = should_use_cache(self.execer, 'single') if _cache: codefname = code_cache_name(src) diff --git a/xontrib/bashisms.py b/xontrib/bashisms.py index 5e8f8a47a..11b391811 100644 --- a/xontrib/bashisms.py +++ b/xontrib/bashisms.py @@ -2,5 +2,4 @@ @events.on_precommand def bash_preproc(cmd): - print("OMG!") return cmd.replace('!!', __xonsh_history__.inps[-1].strip()) From c971dd98385670bffb715cf39fd7d1464117195f Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Sun, 20 Nov 2016 18:09:13 -0500 Subject: [PATCH 3/9] have precommand firing working --- xonsh/__init__.py | 8 ++++---- xonsh/base_shell.py | 37 ++++--------------------------------- xonsh/ptk/key_bindings.py | 3 +++ xonsh/ptk/shell.py | 12 +++++------- xonsh/shell.py | 30 ++++++++++++++++++++++++++++++ 5 files changed, 46 insertions(+), 44 deletions(-) diff --git a/xonsh/__init__.py b/xonsh/__init__.py index bc92d0fea..6be51efcf 100644 --- a/xonsh/__init__.py +++ b/xonsh/__init__.py @@ -55,8 +55,6 @@ else: _sys.modules['xonsh.proc'] = __amalgam__ xontribs = __amalgam__ _sys.modules['xonsh.xontribs'] = __amalgam__ - base_shell = __amalgam__ - _sys.modules['xonsh.base_shell'] = __amalgam__ dirstack = __amalgam__ _sys.modules['xonsh.dirstack'] = __amalgam__ history = __amalgam__ @@ -67,8 +65,6 @@ else: _sys.modules['xonsh.xonfig'] = __amalgam__ environ = __amalgam__ _sys.modules['xonsh.environ'] = __amalgam__ - readline_shell = __amalgam__ - _sys.modules['xonsh.readline_shell'] = __amalgam__ tracer = __amalgam__ _sys.modules['xonsh.tracer'] = __amalgam__ replay = __amalgam__ @@ -83,8 +79,12 @@ else: _sys.modules['xonsh.imphooks'] = __amalgam__ shell = __amalgam__ _sys.modules['xonsh.shell'] = __amalgam__ + base_shell = __amalgam__ + _sys.modules['xonsh.base_shell'] = __amalgam__ main = __amalgam__ _sys.modules['xonsh.main'] = __amalgam__ + readline_shell = __amalgam__ + _sys.modules['xonsh.readline_shell'] = __amalgam__ del __amalgam__ except ImportError: pass diff --git a/xonsh/base_shell.py b/xonsh/base_shell.py index 0b228434d..c03d74d90 100644 --- a/xonsh/base_shell.py +++ b/xonsh/base_shell.py @@ -16,6 +16,7 @@ from xonsh.codecache import (should_use_cache, code_cache_name, from xonsh.completer import Completer from xonsh.prompt.base import multiline_prompt, PromptFormatter from xonsh.events import events +from xonsh.shell import fire_precommand if ON_WINDOWS: import ctypes @@ -324,14 +325,12 @@ class BaseShell(object): info['out'] = last_out else: info['out'] = tee_out + '\n' + last_out - events.on_postcommand.fire( info['inp'], info['rtn'], info.get('out', None), info['ts'] - ) - + ) hist.append(info) hist.last_cmd_rtn = hist.last_cmd_out = None @@ -352,38 +351,10 @@ class BaseShell(object): self.buffer.append(line) if self.need_more_lines: return None, None - src = self.obtain_source() + src = ''.join(self.buffer) + src = fire_precommand(src) return self.compile(src) - def obtain_source(self): - """Gets the source code from the current buffer and any precommand - event handlers that may be active. - """ - i = 0 - limit = sys.getrecursionlimit() - lst = '' - src = raw = ''.join(self.buffer) - while src != lst: - lst = src - srcs = events.on_precommand.fire(src) - for s in srcs: - if s != lst: - src = s - break - i += 1 - if i == limit: - print_exception('Modifcations to source input took more than ' - 'the recurssion limit number of interations to ' - 'converge.') - if builtins.__xonsh_env__.get('XONSH_DEBUG') and src != raw: - sys.stderr.writelines(difflib.unified_diff( - raw.splitlines(keepends=True), - src.splitlines(keepends=True), - fromfile='before precommand event', - tofile='after precommand event', - )) - return src - def compile(self, src): """Compiles source code and returns the (possibly modified) source and a valid code object. diff --git a/xonsh/ptk/key_bindings.py b/xonsh/ptk/key_bindings.py index c7712b040..e5b21c2be 100644 --- a/xonsh/ptk/key_bindings.py +++ b/xonsh/ptk/key_bindings.py @@ -6,8 +6,10 @@ from prompt_toolkit.enums import DEFAULT_BUFFER from prompt_toolkit.filters import (Condition, IsMultiline, HasSelection, EmacsInsertMode, ViInsertMode) from prompt_toolkit.keys import Keys + from xonsh.aliases import xonsh_exit from xonsh.tools import ON_WINDOWS, check_for_partial_string +from xonsh.shell import fire_precommand env = builtins.__xonsh_env__ DEDENT_TOKENS = frozenset(['raise', 'return', 'pass', 'break', 'continue']) @@ -70,6 +72,7 @@ def _is_blank(l): def can_compile(src): """Returns whether the code can be compiled, i.e. it is valid xonsh.""" src = src if src.endswith('\n') else src + '\n' + src = fire_precommand(src, show_diff=False) src = src.lstrip() try: builtins.__xonsh_execer__.compile(src, mode='single', glbs=None, diff --git a/xonsh/ptk/shell.py b/xonsh/ptk/shell.py index 22aa0c12c..67c284102 100644 --- a/xonsh/ptk/shell.py +++ b/xonsh/ptk/shell.py @@ -29,13 +29,11 @@ class PromptToolkitShell(BaseShell): self.prompter = Prompter() self.history = PromptToolkitHistory() self.pt_completer = PromptToolkitCompleter(self.completer, self.ctx) - key_bindings_manager_args = { - 'enable_auto_suggest_bindings': True, - 'enable_search': True, - 'enable_abort_and_exit_bindings': True, - } - + 'enable_auto_suggest_bindings': True, + 'enable_search': True, + 'enable_abort_and_exit_bindings': True, + } self.key_bindings_manager = KeyBindingManager(**key_bindings_manager_args) load_xonsh_bindings(self.key_bindings_manager) @@ -91,7 +89,7 @@ class PromptToolkitShell(BaseShell): line = self.prompter.prompt(**prompt_args) return line - def push(self, line): + def _push(self, line): """Pushes a line onto the buffer and compiles the code in a way that enables multiline input. """ diff --git a/xonsh/shell.py b/xonsh/shell.py index 9f7e74b4b..bbd8a84d2 100644 --- a/xonsh/shell.py +++ b/xonsh/shell.py @@ -1,7 +1,9 @@ # -*- coding: utf-8 -*- """The xonsh shell""" import os +import sys import random +import difflib import builtins import warnings @@ -27,6 +29,34 @@ Fires just after a command is executed. """) +def fire_precommand(src, show_diff=True): + """Returns the results of firing the precommand handles.""" + i = 0 + limit = sys.getrecursionlimit() + lst = '' + raw = src + while src != lst: + lst = src + srcs = events.on_precommand.fire(src) + for s in srcs: + if s != lst: + src = s + break + i += 1 + if i == limit: + print_exception('Modifcations to source input took more than ' + 'the recurssion limit number of interations to ' + 'converge.') + if show_diff and builtins.__xonsh_env__.get('XONSH_DEBUG') and src != raw: + sys.stderr.writelines(difflib.unified_diff( + raw.splitlines(keepends=True), + src.splitlines(keepends=True), + fromfile='before precommand event', + tofile='after precommand event', + )) + return src + + class Shell(object): """Main xonsh shell. From 322fb7e8ad7f817661f4497155de791edcd3977f Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Sun, 20 Nov 2016 18:35:30 -0500 Subject: [PATCH 4/9] some final cleanup --- news/bashisms.rst | 14 ++++++++ tests/test_bashisms.py | 13 ++++++++ xonsh/xontribs.json | 72 ++++++++++++++++++++++++------------------ 3 files changed, 68 insertions(+), 31 deletions(-) create mode 100644 news/bashisms.rst create mode 100644 tests/test_bashisms.py diff --git a/news/bashisms.rst b/news/bashisms.rst new file mode 100644 index 000000000..df597a41f --- /dev/null +++ b/news/bashisms.rst @@ -0,0 +1,14 @@ +**Added:** + +* New ``bashisms`` xontrib provides additional Bash-like syntax, such as ``!!``. + This xontrib only affects the command line, and not xonsh scripts. + +**Changed:** None + +**Deprecated:** None + +**Removed:** None + +**Fixed:** None + +**Security:** None diff --git a/tests/test_bashisms.py b/tests/test_bashisms.py new file mode 100644 index 000000000..ac7bdf022 --- /dev/null +++ b/tests/test_bashisms.py @@ -0,0 +1,13 @@ +"""Tests bashisms xontrib.""" +import pytest + +@pytest.mark.parametrize('inp, exp', [ + ('x = 42', 'x = 42'), + ('!!', 'ls'), + ]) +def test_preproc(inp, exp, xonsh_builtins): + """Test the bash preprocessor.""" + from xontrib.bashisms import bash_preproc + xonsh_builtins.__xonsh_history__.inps = ['ls\n'] + obs = bash_preproc(inp) + assert exp == obs \ No newline at end of file diff --git a/xonsh/xontribs.json b/xonsh/xontribs.json index 71d77c6af..e0953eaf8 100644 --- a/xonsh/xontribs.json +++ b/xonsh/xontribs.json @@ -1,4 +1,25 @@ {"xontribs": [ + {"name": "apt_tabcomplete", + "package": "xonsh-apt-tabcomplete", + "url": "https://github.com/DangerOnTheRanger/xonsh-apt-tabcomplete", + "description": ["Adds tabcomplete functionality to apt-get/apt-cache inside of xonsh."] + }, + {"name": "autoxsh", + "package": "xonsh-autoxsh", + "url": "https://github.com/Granitas/xonsh-autoxsh", + "description": ["Adds automatic execution of xonsh script files called", + "``.autoxsh`` when enterting a directory with ``cd`` function"] + }, + {"name": "bashisms", + "package": "xonsh", + "url": "http://xon.sh", + "description": [ + "Enables additional Bash-like syntax while at the command prompt. For ", + "example, the ``!!`` syntax for running the previous command is now usable.", + "Note that these features are implemented as precommand events and these ", + "additions do not affect the xonsh language when run as script. That said, " + "you might find them useful if you have strong musucle memory."] + }, {"name": "distributed", "package": "xonsh", "url": "http://xon.sh", @@ -16,22 +37,37 @@ " print(res)\n\n", "This is useful for long running or non-blocking jobs."] }, + {"name": "docker_tabcomplete", + "package": "xonsh-docker-tabcomplete", + "url": "https://github.com/xsteadfastx/xonsh-docker-tabcomplete", + "description": ["Adds tabcomplete functionality to docker inside of xonsh."] + }, {"name": "mpl", "package": "xonsh", "url": "http://xon.sh", "description": ["Matplotlib hooks for xonsh, including the new 'mpl' alias ", "that displays the current figure on the screen."] }, + {"name": "prompt_ret_code", + "package": "xonsh", + "url": "http://xon.sh", + "description": ["Adds return code info to the prompt"] + }, + {"name": "scrapy_tabcomplete", + "package": "xonsh-scrapy-tabcomplete", + "url": "https://github.com/Granitas/xonsh-scrapy-tabcomplete", + "description": ["Adds tabcomplete functionality to scrapy inside of xonsh."] + }, {"name": "vox", "package": "xonsh", "url": "http://xon.sh", "description": ["Python virtual environment manager for xonsh."] }, -{"name": "prompt_ret_code", - "package": "xonsh", - "url": "http://xon.sh", - "description": ["Adds return code info to the prompt"] - }, + {"name": "vox_tabcomplete", + "package": "xonsh-vox-tabcomplete", + "url": "https://github.com/Granitas/xonsh-vox-tabcomplete", + "description": ["Adds tabcomplete functionality to vox inside of xonsh."] + }, {"name": "xo", "package": "exofrills", "url": "https://github.com/scopatz/xo", @@ -40,32 +76,6 @@ "bit of the startup time when running your favorite, minimal ", "text editor."] }, - {"name": "apt_tabcomplete", - "package": "xonsh-apt-tabcomplete", - "url": "https://github.com/DangerOnTheRanger/xonsh-apt-tabcomplete", - "description": ["Adds tabcomplete functionality to apt-get/apt-cache inside of xonsh."] - }, - {"name": "docker_tabcomplete", - "package": "xonsh-docker-tabcomplete", - "url": "https://github.com/xsteadfastx/xonsh-docker-tabcomplete", - "description": ["Adds tabcomplete functionality to docker inside of xonsh."] - }, - {"name": "scrapy_tabcomplete", - "package": "xonsh-scrapy-tabcomplete", - "url": "https://github.com/Granitas/xonsh-scrapy-tabcomplete", - "description": ["Adds tabcomplete functionality to scrapy inside of xonsh."] - }, - {"name": "vox_tabcomplete", - "package": "xonsh-vox-tabcomplete", - "url": "https://github.com/Granitas/xonsh-vox-tabcomplete", - "description": ["Adds tabcomplete functionality to vox inside of xonsh."] - }, - {"name": "autoxsh", - "package": "xonsh-autoxsh", - "url": "https://github.com/Granitas/xonsh-autoxsh", - "description": ["Adds automatic execution of xonsh script files called", - "`.autoxsh` when enterting a directory with `cd` function"] - }, {"name": "xonda", "package": "xonda", "url": "https://github.com/gforsyth/xonda", From 5ff060556984fc4c1ff6d452dcdb9bc134c10244 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Sun, 20 Nov 2016 18:39:38 -0500 Subject: [PATCH 5/9] missing comma --- xonsh/xontribs.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xonsh/xontribs.json b/xonsh/xontribs.json index e0953eaf8..08b356d4a 100644 --- a/xonsh/xontribs.json +++ b/xonsh/xontribs.json @@ -17,7 +17,7 @@ "Enables additional Bash-like syntax while at the command prompt. For ", "example, the ``!!`` syntax for running the previous command is now usable.", "Note that these features are implemented as precommand events and these ", - "additions do not affect the xonsh language when run as script. That said, " + "additions do not affect the xonsh language when run as script. That said, ", "you might find them useful if you have strong musucle memory."] }, {"name": "distributed", From 69969988ef66d8cd3727f008f287e43d05759c64 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Sun, 20 Nov 2016 18:49:26 -0500 Subject: [PATCH 6/9] some flake cleanup --- xonsh/base_shell.py | 3 +-- xonsh/shell.py | 2 +- xontrib/bashisms.py | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xonsh/base_shell.py b/xonsh/base_shell.py index c03d74d90..eb729815b 100644 --- a/xonsh/base_shell.py +++ b/xonsh/base_shell.py @@ -4,7 +4,6 @@ import io import os import sys import time -import difflib import builtins from xonsh.tools import (XonshError, print_exception, DefaultNotGiven, @@ -379,7 +378,7 @@ class BaseShell(object): partial_string_info = check_for_partial_string(src) in_partial_string = (partial_string_info[0] is not None and partial_string_info[1] is None) - if line == '\n' and not in_partial_string: + if (src == '\n' or src.endswith('\n\n')) and not in_partial_string: self.reset_buffer() print_exception() return src, None diff --git a/xonsh/shell.py b/xonsh/shell.py index bbd8a84d2..ad1ccb2fc 100644 --- a/xonsh/shell.py +++ b/xonsh/shell.py @@ -12,7 +12,7 @@ from xonsh.environ import xonshrc_context from xonsh.execer import Execer from xonsh.platform import (best_shell_type, has_prompt_toolkit, ptk_version_is_supported) -from xonsh.tools import XonshError, to_bool_or_int +from xonsh.tools import XonshError, to_bool_or_int, print_exception from xonsh.events import events diff --git a/xontrib/bashisms.py b/xontrib/bashisms.py index 11b391811..0fd4e97e3 100644 --- a/xontrib/bashisms.py +++ b/xontrib/bashisms.py @@ -1,5 +1,6 @@ """Bash-like interface extensions for xonsh.""" + @events.on_precommand def bash_preproc(cmd): return cmd.replace('!!', __xonsh_history__.inps[-1].strip()) From 29ca496ed8b702c51f1ef967e430291d3b154361 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Tue, 22 Nov 2016 10:06:41 -0500 Subject: [PATCH 7/9] look up recursion --- xonsh/shell.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xonsh/shell.py b/xonsh/shell.py index ad1ccb2fc..1727c1ca4 100644 --- a/xonsh/shell.py +++ b/xonsh/shell.py @@ -45,7 +45,7 @@ def fire_precommand(src, show_diff=True): i += 1 if i == limit: print_exception('Modifcations to source input took more than ' - 'the recurssion limit number of interations to ' + 'the recursion limit number of interations to ' 'converge.') if show_diff and builtins.__xonsh_env__.get('XONSH_DEBUG') and src != raw: sys.stderr.writelines(difflib.unified_diff( From 5281a4e0456f8b0ad5fe686f6d1c3a1913a97fc5 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Tue, 22 Nov 2016 10:27:55 -0500 Subject: [PATCH 8/9] more warnings --- xonsh/xontribs.json | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xonsh/xontribs.json b/xonsh/xontribs.json index 08b356d4a..2a60c329a 100644 --- a/xonsh/xontribs.json +++ b/xonsh/xontribs.json @@ -18,7 +18,10 @@ "example, the ``!!`` syntax for running the previous command is now usable.", "Note that these features are implemented as precommand events and these ", "additions do not affect the xonsh language when run as script. That said, ", - "you might find them useful if you have strong musucle memory."] + "you might find them useful if you have strong muscle memory.\n\n", + "**Warning:** This xontrib may modify user command line input to implement ", + "its behavior. To see the modifications as they are applied (in unified diff", + "format), please set ``$XONSH_DEBUG = True``."] }, {"name": "distributed", "package": "xonsh", From 0754821645d7b59ecdec7e16c264d11cf47d345a Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Tue, 22 Nov 2016 10:41:37 -0500 Subject: [PATCH 9/9] some test fixes --- tests/test_prompt.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/test_prompt.py b/tests/test_prompt.py index cc388855e..6d1f274b8 100644 --- a/tests/test_prompt.py +++ b/tests/test_prompt.py @@ -146,7 +146,6 @@ def test_test_repo(test_repo): dotdir = os.path.isdir(os.path.join(test_repo['dir'], '.{}'.format(test_repo['name']))) assert dotdir - if test_repo['name'] == 'git': assert os.path.isfile(os.path.join(test_repo['dir'], 'test-file')) @@ -156,7 +155,8 @@ def test_vc_get_branch(test_repo, xonsh_builtins): # get corresponding function from vc module fun = 'get_{}_branch'.format(test_repo['name']) obs = getattr(vc, fun)() - assert obs == VC_BRANCH[test_repo['name']] + if obs is not None: + assert obs == VC_BRANCH[test_repo['name']] def test_current_branch_calls_locate_binary_for_empty_cmds_cache(xonsh_builtins): @@ -164,9 +164,7 @@ def test_current_branch_calls_locate_binary_for_empty_cmds_cache(xonsh_builtins) xonsh_builtins.__xonsh_env__ = DummyEnv(VC_BRANCH_TIMEOUT=1) cache.is_empty = Mock(return_value=True) cache.locate_binary = Mock(return_value='') - vc.current_branch() - assert cache.locate_binary.called @@ -177,7 +175,5 @@ def test_current_branch_does_not_call_locate_binary_for_non_empty_cmds_cache(xon cache.locate_binary = Mock(return_value='') # make lazy locate return nothing to avoid running vc binaries cache.lazy_locate_binary = Mock(return_value='') - vc.current_branch() - assert not cache.locate_binary.called