##// END OF EJS Templates
Finishing conversion of templates to use single style.*.
Finishing conversion of templates to use single style.*.

File last commit:

r8588:2bfb3b77
r10717:4780e5ad
Show More
test_console_widget.py
80 lines | 2.8 KiB | text/x-python | PythonLexer
/ IPython / frontend / qt / console / tests / test_console_widget.py
Puneeth Chaganti
TST: Add tests to check the actual output on the console.
r6437 # Standard library imports
import unittest
# System library imports
Diane Trout
Test _anchor tracking in response to mouseMoveEvent Messages...
r8533 from IPython.external.qt import QtCore, QtGui
Puneeth Chaganti
TST: Add tests to check the actual output on the console.
r6437
# Local imports
from IPython.frontend.qt.console.console_widget import ConsoleWidget
class TestConsoleWidget(unittest.TestCase):
@classmethod
def setUpClass(cls):
""" Create the application for the test case.
"""
Puneeth Chaganti
TST: QApplication doesn't quit early enough with PySide....
r6574 cls._app = QtGui.QApplication.instance()
if cls._app is None:
cls._app = QtGui.QApplication([])
Puneeth Chaganti
TST: Add tests to check the actual output on the console.
r6437 cls._app.setQuitOnLastWindowClosed(False)
@classmethod
def tearDownClass(cls):
""" Exit the application.
"""
QtGui.QApplication.quit()
def test_special_characters(self):
""" Are special characters displayed correctly?
"""
w = ConsoleWidget()
cursor = w._get_prompt_cursor()
test_inputs = ['xyz\b\b=\n', 'foo\b\nbar\n', 'foo\b\nbar\r\n', 'abc\rxyz\b\b=']
expected_outputs = [u'x=z\u2029', u'foo\u2029bar\u2029', u'foo\u2029bar\u2029', 'x=z']
for i, text in enumerate(test_inputs):
w._insert_plain_text(cursor, text)
cursor.select(cursor.Document)
selection = cursor.selectedText()
Bradley M. Froehle
s/assertEquals/assertEqual/
r7874 self.assertEqual(expected_outputs[i], selection)
Puneeth Chaganti
TST: Add tests to check the actual output on the console.
r6437 # clear all the text
cursor.insertText('')
Diane Trout
Test _anchor tracking in response to mouseMoveEvent Messages...
r8533
def test_link_handling(self):
Diane Trout
Update ConsoleWidget anchor handling test code....
r8540 noKeys = QtCore.Qt
noButton = QtCore.Qt.MouseButton(0)
noButtons = QtCore.Qt.MouseButtons(0)
noModifiers = QtCore.Qt.KeyboardModifiers(0)
MouseMove = QtCore.QEvent.MouseMove
QMouseEvent = QtGui.QMouseEvent
Diane Trout
Test _anchor tracking in response to mouseMoveEvent Messages...
r8533 w = ConsoleWidget()
cursor = w._get_prompt_cursor()
w._insert_html(cursor, '<a href="http://python.org">written in</a>')
Diane Trout
Update ConsoleWidget anchor handling test code....
r8540 obj = w._control
Diane Trout
Remove self._anchor...
r8588 tip = QtGui.QToolTip
self.assertEqual(tip.text(), u'')
Diane Trout
Update ConsoleWidget anchor handling test code....
r8540
Diane Trout
Remove self._anchor...
r8588 # should be somewhere else
elsewhereEvent = QMouseEvent(MouseMove, QtCore.QPoint(50,50),
noButton, noButtons, noModifiers)
w.eventFilter(obj, elsewhereEvent)
self.assertEqual(tip.isVisible(), False)
self.assertEqual(tip.text(), u'')
#self.assertEqual(tip.text(), u'')
Diane Trout
Test _anchor tracking in response to mouseMoveEvent Messages...
r8533 # should be over text
Diane Trout
Update ConsoleWidget anchor handling test code....
r8540 overTextEvent = QMouseEvent(MouseMove, QtCore.QPoint(1,5),
noButton, noButtons, noModifiers)
w.eventFilter(obj, overTextEvent)
Diane Trout
Remove self._anchor...
r8588 self.assertEqual(tip.isVisible(), True)
self.assertEqual(tip.text(), "http://python.org")
Diane Trout
Update ConsoleWidget anchor handling test code....
r8540
Diane Trout
Test _anchor tracking in response to mouseMoveEvent Messages...
r8533 # should still be over text
Diane Trout
Update ConsoleWidget anchor handling test code....
r8540 stillOverTextEvent = QMouseEvent(MouseMove, QtCore.QPoint(1,5),
noButton, noButtons, noModifiers)
w.eventFilter(obj, stillOverTextEvent)
Diane Trout
Remove self._anchor...
r8588 self.assertEqual(tip.isVisible(), True)
self.assertEqual(tip.text(), "http://python.org")
Diane Trout
Update ConsoleWidget anchor handling test code....
r8540