##// END OF EJS Templates
Update COPYING.txt...
Update COPYING.txt Don't exclude other projects Added new line Don't specify that the comment token in Javascript is different from Python. Fix line break Update 3-clause line

File last commit:

r11970:f7cdf1ff
r15988:4265cfef
Show More
test_console_widget.py
82 lines | 2.9 KiB | text/x-python | PythonLexer
/ IPython / 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
Fernando Perez
Fix all remaining imports that used `IPython.frontend`.
r11024 from IPython.qt.console.console_widget import ConsoleWidget
Paul Ivanov
skip tests when display variable is not set
r11970 import IPython.testing.decorators as dec
Puneeth Chaganti
TST: Add tests to check the actual output on the console.
r6437
Paul Ivanov
skip tests when display variable is not set
r11970 setup = dec.skip_file_no_x11(__name__)
Puneeth Chaganti
TST: Add tests to check the actual output on the console.
r6437
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