This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mock | |
# Example of patching QErrorMessage. Check that an error message is shown. | |
@mock.patch("PyQt4.QtGui.QErrorMessage", autospec=True) | |
def test_onSessionCreateFailed(self, MockErrorMessage): | |
self.widget.onSessionCreateFailed(ValueError("This is a test")) | |
self.assertTrue(MockErrorMessage.return_value.showMessage.called) | |
# example of mocking a method | |
dummyServer.getAllActiveJobs = mock.Mock(return_value=TEST_JOBS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
from PyQt4 import QtGui | |
from PyQt4 import QtCore | |
from PyQt4.QtCore import Qt | |
class DragFromWidget(QtGui.QDockWidget): | |
def __init__(self, parent=None): | |
super(DragFromWidget, self).__init__(parent=parent) |