def test_in_arg_placeholder(self): """Test starting editor with placeholder argument inside argument.""" editor.config = stubs.ConfigStub( {'general': {'editor': ['bin', 'foo{}bar'], 'editor-encoding': 'utf-8'}}) self.editor.edit("") self.editor._proc.start.assert_called_with("bin", ["foo{}bar"])
def test_start_args(self): """Test starting editor with static arguments.""" editor.config = stubs.ConfigStub( {'general': {'editor': ['bin', 'foo', 'bar'], 'editor-encoding': 'utf-8'}}) self.editor.edit("") self.editor._proc.start.assert_called_with("bin", ["foo", "bar"])
def setUp(self): self.editor = editor.ExternalEditor(0) editor.config = stubs.ConfigStub( {'general': { 'editor': [''], 'editor-encoding': 'utf-8' }})
def test_applet_false(self): """Test applet-element with insert-mode-on-plugins false.""" webelem.config = stubs.ConfigStub( {'input': { 'insert-mode-on-plugins': False }}) elem = get_webelem(tagname='applet') self.assertFalse(elem.is_editable())
def test_embed_true(self): """Test embed-element with insert-mode-on-plugins true.""" webelem.config = stubs.ConfigStub( {'input': { 'insert-mode-on-plugins': True }}) elem = get_webelem(tagname='embed') self.assertTrue(elem.is_editable())
def setUp(self): self.editor = editor.ExternalEditor(0) self.editor.editing_finished = mock.Mock() editor.config = stubs.ConfigStub( {'general': { 'editor': [''], 'editor-encoding': 'utf-8' }})
def test_object_application_false(self): """Test object-element with application type but not ...-on-plugins.""" webelem.config = stubs.ConfigStub( {'input': { 'insert-mode-on-plugins': False }}) elem = get_webelem(tagname='object', attributes={'type': 'application/foo'}) self.assertFalse(elem.is_editable())
def test_placeholder(self): """Test starting editor with placeholder argument.""" editor.config = stubs.ConfigStub( {'general': {'editor': ['bin', 'foo', '{}', 'bar'], 'editor-encoding': 'utf-8'}}) self.editor.edit("") filename = self.editor._filename self.editor._proc.start.assert_called_with("bin", ["foo", filename, "bar"])
def test_simple_start_args(self): """Test starting editor without arguments.""" editor.config = stubs.ConfigStub( {'general': { 'editor': ['bin'], 'editor-encoding': 'utf-8' }}) self.editor.edit("") self.editor._proc.start.assert_called_with("bin", [])
def test_object_classid_false(self): """Test object-element with classid but not insert-mode-on-plugins.""" webelem.config = stubs.ConfigStub( {'input': { 'insert-mode-on-plugins': False }}) elem = get_webelem(tagname='object', attributes={ 'type': 'foo', 'classid': 'foo' }) self.assertFalse(elem.is_editable())
def test_ambigious_keychain(self): """Test ambigious keychain.""" basekeyparser.config = stubs.ConfigStub(CONFIG) # We start with 'a' where the keychain gives us an ambigious result. # Then we check if the timer has been set up correctly self.kp.handle(helpers.fake_keyevent(Qt.Key_A, text='a')) self.assertFalse(self.kp.execute.called) basekeyparser.usertypes.Timer.assert_called_once_with( self.kp, 'ambigious_match') self.timermock.setSingleShot.assert_called_once_with(True) self.timermock.setInterval.assert_called_once_with(100) self.assertTrue(self.timermock.timeout.connect.called) self.assertFalse(self.timermock.stop.called) self.timermock.start.assert_called_once_with() # Now we type an 'x' and check 'ax' has been executed and the timer # stopped. self.kp.handle(helpers.fake_keyevent(Qt.Key_X, text='x')) self.kp.execute.assert_called_once_with('ax', self.kp.Type.chain, None) self.timermock.stop.assert_called_once_with() self.assertEqual(self.kp._keystring, '')
def setUp(self): self.config = urlutils.config urlutils.config = stubs.ConfigStub(CONFIG)