Exemplo n.º 1
0
def test_debug_trace(mocker):
    """Check if hunter.trace is properly called."""
    # but only if hunter is available
    pytest.importorskip('hunter')
    hunter_mock = mocker.patch('qutebrowser.misc.utilcmds.hunter')
    utilcmds.debug_trace(1)
    hunter_mock.trace.assert_called_with(1)
Exemplo n.º 2
0
def test_debug_trace(mocker):
    """Check if hunter.trace is properly called."""
    # but only if hunter is available
    pytest.importorskip('hunter')
    hunter_mock = mocker.patch('qutebrowser.misc.utilcmds.hunter')
    utilcmds.debug_trace(1)
    assert hunter_mock.trace.assert_called_with(1)
Exemplo n.º 3
0
def test_debug_trace_no_hunter(monkeypatch):
    """Test that an error is shown if debug_trace is called without hunter."""
    monkeypatch.setattr(utilcmds, 'hunter', None)
    with pytest.raises(cmdexc.CommandError) as excinfo:
        utilcmds.debug_trace()
    assert str(excinfo.value) == "You need to install 'hunter' to use this " \
                                 "command!"
Exemplo n.º 4
0
def test_debug_trace_no_hunter(monkeypatch):
    """Test that an error is shown if debug_trace is called without hunter."""
    monkeypatch.setattr(utilcmds, 'hunter', None)
    with pytest.raises(cmdexc.CommandError,
                       match="You need to install "
                       "'hunter' to use this command!"):
        utilcmds.debug_trace()
Exemplo n.º 5
0
def test_debug_trace_exception(mocker):
    """Check that exceptions thrown by hunter.trace are handled."""
    def _mock_exception():
        """Side effect for testing debug_trace's reraise."""
        raise Exception('message')

    hunter_mock = mocker.patch('qutebrowser.misc.utilcmds.hunter')
    hunter_mock.trace.side_effect = _mock_exception
    with pytest.raises(cmdexc.CommandError, match='Exception: message'):
        utilcmds.debug_trace()
Exemplo n.º 6
0
def test_debug_trace_exception(mocker):
    """Check that exceptions thrown by hunter.trace are handled."""
    def _mock_exception():
        """Side effect for testing debug_trace's reraise."""
        raise Exception('message')

    hunter_mock = mocker.patch('qutebrowser.misc.utilcmds.hunter')
    hunter_mock.trace.side_effect = _mock_exception
    with pytest.raises(cmdexc.CommandError, match='Exception: message'):
        utilcmds.debug_trace()
Exemplo n.º 7
0
def test_debug_trace_no_hunter(monkeypatch):
    """Test that an error is shown if debug_trace is called without hunter."""
    monkeypatch.setattr(utilcmds, 'hunter', None)
    with pytest.raises(cmdexc.CommandError, match="You need to install "
                       "'hunter' to use this command!"):
        utilcmds.debug_trace()