Example #1
0
def test_current_branch_calls_locate_binary_for_empty_cmds_cache(xonsh_builtins):
    cache = xonsh_builtins.__xonsh__.commands_cache
    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
Example #2
0
def test_current_branch_calls_locate_binary_for_empty_cmds_cache(
        xession, monkeypatch):
    cache = xession.commands_cache
    monkeypatch.setattr(cache, "is_empty", Mock(return_value=True))
    monkeypatch.setattr(cache, "locate_binary", Mock(return_value=""))
    vc.current_branch()
    assert cache.locate_binary.called
Example #3
0
def test_current_branch_does_not_call_locate_binary_for_non_empty_cmds_cache(xonsh_builtins):
    cache = xonsh_builtins.__xonsh_commands_cache__
    xonsh_builtins.__xonsh_env__ = DummyEnv(VC_BRANCH_TIMEOUT=1)
    cache.is_empty = Mock(return_value=False)
    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
Example #4
0
def test_current_branch_does_not_call_locate_binary_for_non_empty_cmds_cache(xonsh_builtins):
    cache = xonsh_builtins.__xonsh_commands_cache__
    xonsh_builtins.__xonsh_env__ = DummyEnv(VC_BRANCH_TIMEOUT=1)
    cache.is_empty = Mock(return_value=False)
    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
Example #5
0
def test_current_branch_does_not_call_locate_binary_for_non_empty_cmds_cache(
    xession,
    monkeypatch,
):
    cache = xession.commands_cache
    monkeypatch.setattr(cache, "is_empty", Mock(return_value=False))
    monkeypatch.setattr(cache, "locate_binary", Mock(return_value=""))
    # make lazy locate return nothing to avoid running vc binaries
    monkeypatch.setattr(cache, "lazy_locate_binary", Mock(return_value=""))
    vc.current_branch()
    assert not cache.locate_binary.called