def test_popup(self): entry = ProxyEntry() entry.data_type = currency entry.set_text('150') calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB) event = gtk.gdk.Event(gtk.gdk.BUTTON_PRESS) event.window = gtk.gdk.get_default_root_window() with mock.patch.object(calc, 'popup') as popup: entry.emit('icon-press', gtk.ENTRY_ICON_PRIMARY, event) self.assertEqual(popup.call_count, 0) entry.emit('icon-press', gtk.ENTRY_ICON_SECONDARY, event) popup.assert_called_once()
def test_popup(self): entry = ProxyEntry() entry.data_type = currency entry.set_text('150') calc = CalculatorPopup(entry, CalculatorPopup.MODE_SUB) event = Gdk.Event.new(Gdk.EventType.BUTTON_PRESS) event.window = Gdk.get_default_root_window() with mock.patch.object(calc, 'popup') as popup: entry.emit('icon-press', Gtk.EntryIconPosition.PRIMARY, event) self.assertEqual(popup.call_count, 0) entry.emit('icon-press', Gtk.EntryIconPosition.SECONDARY, event) self.assertEqual(popup.call_count, 1)