source: orange/Orange/OrangeCanvas/application/tests/test_outputview.py @ 11167:74773cf295d6

Revision 11167:74773cf295d6, 1018 bytes checked in by Ales Erjavec <ales.erjavec@…>, 18 months ago (diff)

Added 'Output' window showing redirected stdout/stderr.

Line 
1from datetime import datetime
2
3from ...gui.test import QAppTestCase
4
5from ..outputview import OutputText
6
7
8class TestOutputView(QAppTestCase):
9    def test_outputview(self):
10        output = OutputText()
11        output.show()
12
13        line1 = "A line \n"
14        line2 = "A different line\n"
15        output.write(line1)
16        self.assertEqual(unicode(output.toPlainText()), line1)
17
18        output.write(line2)
19        self.assertEqual(unicode(output.toPlainText()), line1 + line2)
20
21        output.clear()
22        self.assertEqual(unicode(output.toPlainText()), "")
23
24        output.writelines([line1, line2])
25        self.assertEqual(unicode(output.toPlainText()), line1 + line2)
26
27        output.setMaximumLines(5)
28
29        def advance():
30            now = datetime.now().strftime("%c\n")
31            output.write(now)
32
33            text = unicode(output.toPlainText())
34            self.assertLessEqual(len(text.splitlines()), 5)
35
36            self.singleShot(500, advance)
37
38        advance()
39
40        self.app.exec_()
Note: See TracBrowser for help on using the repository browser.