/usr/lib/python3/dist-packages/qtconsole/tests/test_completion_widget.py is in python3-qtconsole 4.3.1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | # -*- coding: utf-8 -*-
import unittest
from qtconsole.qt import QtCore, QtGui
from qtconsole.qt_loaders import load_qtest
from qtconsole.console_widget import ConsoleWidget
from qtconsole.completion_widget import CompletionWidget
import ipython_genutils.testing.decorators as dec
QTest = load_qtest()
setup = dec.skip_file_no_x11(__name__)
class TestCompletionWidget(unittest.TestCase):
@classmethod
def setUpClass(cls):
""" Create the application for the test case.
"""
cls._app = QtGui.QApplication.instance()
if cls._app is None:
cls._app = QtGui.QApplication([])
cls._app.setQuitOnLastWindowClosed(False)
@classmethod
def tearDownClass(cls):
""" Exit the application.
"""
QtGui.QApplication.quit()
def setUp(self):
""" Create the main widgets (ConsoleWidget)
"""
self.console = ConsoleWidget()
self.text_edit = self.console._control
def test_droplist_completer_shows(self):
w = CompletionWidget(self.console)
w.show_items(self.text_edit.textCursor(), ["item1", "item2", "item3"])
self.assertTrue(w.isVisible())
def test_droplist_completer_keyboard(self):
w = CompletionWidget(self.console)
w.show_items(self.text_edit.textCursor(), ["item1", "item2", "item3"])
QTest.keyClick(w, QtCore.Qt.Key_PageDown)
QTest.keyClick(w, QtCore.Qt.Key_Enter)
self.assertEqual(self.text_edit.toPlainText(), "item3")
def test_droplist_completer_mousepick(self):
leftButton = QtCore.Qt.LeftButton
w = CompletionWidget(self.console)
w.show_items(self.text_edit.textCursor(), ["item1", "item2", "item3"])
QTest.mouseClick(w.viewport(), leftButton, pos=QtCore.QPoint(19, 8))
QTest.mouseRelease(w.viewport(), leftButton, pos=QtCore.QPoint(19, 8))
QTest.mouseDClick(w.viewport(), leftButton, pos=QtCore.QPoint(19, 8))
self.assertEqual(self.text_edit.toPlainText(), "item1")
self.assertFalse(w.isVisible())
|