Use .assert_not_called() for mocks
This commit is contained in:
parent
e27c54a5c1
commit
4e46c34e5a
@ -36,8 +36,8 @@ def test_timeout(timer):
|
||||
func2 = mock.Mock()
|
||||
timer.timeout.connect(func)
|
||||
timer.timeout.connect(func2)
|
||||
assert not func.called
|
||||
assert not func2.called
|
||||
func.assert_not_called()
|
||||
func2.assert_not_called()
|
||||
timer.timeout.emit()
|
||||
func.assert_called_once_with()
|
||||
func2.assert_called_once_with()
|
||||
@ -49,7 +49,7 @@ def test_disconnect_all(timer):
|
||||
timer.timeout.connect(func)
|
||||
timer.timeout.disconnect()
|
||||
timer.timeout.emit()
|
||||
assert not func.called
|
||||
func.assert_not_called()
|
||||
|
||||
|
||||
def test_disconnect_one(timer):
|
||||
@ -58,7 +58,7 @@ def test_disconnect_one(timer):
|
||||
timer.timeout.connect(func)
|
||||
timer.timeout.disconnect(func)
|
||||
timer.timeout.emit()
|
||||
assert not func.called
|
||||
func.assert_not_called()
|
||||
|
||||
|
||||
def test_disconnect_all_invalid(timer):
|
||||
@ -74,8 +74,8 @@ def test_disconnect_one_invalid(timer):
|
||||
timer.timeout.connect(func1)
|
||||
with pytest.raises(TypeError):
|
||||
timer.timeout.disconnect(func2)
|
||||
assert not func1.called
|
||||
assert not func2.called
|
||||
func1.assert_not_called()
|
||||
func2.assert_not_called()
|
||||
timer.timeout.emit()
|
||||
func1.assert_called_once_with()
|
||||
|
||||
|
@ -103,7 +103,7 @@ def test_delete_cur_item_no_func():
|
||||
parent = model.index(0, 0)
|
||||
with pytest.raises(cmdexc.CommandError):
|
||||
model.delete_cur_item(model.index(0, 0, parent))
|
||||
assert not callback.called
|
||||
callback.assert_not_called()
|
||||
|
||||
|
||||
def test_delete_cur_item_no_cat():
|
||||
@ -114,4 +114,4 @@ def test_delete_cur_item_no_cat():
|
||||
model.rowsRemoved.connect(callback)
|
||||
with pytest.raises(qtutils.QtValueError):
|
||||
model.delete_cur_item(QModelIndex())
|
||||
assert not callback.called
|
||||
callback.assert_not_called()
|
||||
|
@ -242,7 +242,7 @@ def test_completion_item_del_no_selection(completionview):
|
||||
completionview.set_model(model)
|
||||
with pytest.raises(cmdexc.CommandError, match='No item selected!'):
|
||||
completionview.completion_item_del()
|
||||
assert not func.called
|
||||
func.assert_not_called()
|
||||
|
||||
|
||||
def test_resize_no_model(completionview, qtbot):
|
||||
|
@ -151,7 +151,7 @@ def test_late_init(init_patch, monkeypatch, fake_save_manager, fake_args,
|
||||
assert text.startswith('Errors occurred while reading config.py:')
|
||||
assert '<b>Error text</b>: Exception' in text
|
||||
else:
|
||||
assert not msgbox_mock.called
|
||||
msgbox_mock.assert_not_called()
|
||||
|
||||
|
||||
class TestQtArgs:
|
||||
|
@ -380,7 +380,7 @@ class TestHandleConnection:
|
||||
monkeypatch.setattr(ipc_server._server, 'nextPendingConnection', m)
|
||||
ipc_server.ignored = True
|
||||
ipc_server.handle_connection()
|
||||
assert not m.called
|
||||
m.assert_not_called()
|
||||
|
||||
def test_no_connection(self, ipc_server, caplog):
|
||||
ipc_server.handle_connection()
|
||||
|
@ -494,17 +494,17 @@ def test_init(mocker, tmpdir, args_kind):
|
||||
assert standarddir._locations != {}
|
||||
if args_kind == 'normal':
|
||||
if utils.is_mac:
|
||||
assert not m_windows.called
|
||||
m_windows.assert_not_called()
|
||||
assert m_mac.called
|
||||
elif utils.is_windows:
|
||||
assert m_windows.called
|
||||
assert not m_mac.called
|
||||
m_mac.assert_not_called()
|
||||
else:
|
||||
assert not m_windows.called
|
||||
assert not m_mac.called
|
||||
m_windows.assert_not_called()
|
||||
m_mac.assert_not_called()
|
||||
else:
|
||||
assert not m_windows.called
|
||||
assert not m_mac.called
|
||||
m_windows.assert_not_called()
|
||||
m_mac.assert_not_called()
|
||||
|
||||
|
||||
@pytest.mark.linux
|
||||
|
Loading…
Reference in New Issue
Block a user