aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorAnderson Lizardo <anderson.lizardo@openbossa.org>2010-02-23 10:26:14 -0400
committerMarcelo Lira <marcelo.lira@openbossa.org>2010-02-23 19:32:16 -0300
commit46f20f137ca789fd6a26eb4ce0f2360c91258c21 (patch)
treef4b22b58989e3b6d79b5b51552f79aca47c68fa1 /tests
parent30bc9ff03841fe4866d6faa18fa6623902c4dd59 (diff)
Add tests/qtgui/qtextedit_test.py
Diffstat (limited to 'tests')
-rw-r--r--tests/qtgui/qtextedit_test.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/qtgui/qtextedit_test.py b/tests/qtgui/qtextedit_test.py
new file mode 100644
index 000000000..442cbe2cf
--- /dev/null
+++ b/tests/qtgui/qtextedit_test.py
@@ -0,0 +1,32 @@
+'''Test cases for QTextEdit and ownership problems.'''
+
+import unittest
+from sys import getrefcount
+from PySide.QtGui import QTextEdit
+
+from helper import UsesQApplication
+
+class DontTouchReference(UsesQApplication):
+ '''Check if the QTextTable returned by QTextCursor.insertTable() is not
+ referenced by the QTextCursor that returns it.'''
+
+ def setUp(self):
+ super(DontTouchReference, self).setUp()
+ self.editor = QTextEdit()
+ self.cursor = self.editor.textCursor()
+ self.table = self.cursor.insertTable(1, 1)
+
+ def testQTextTable(self):
+ # methods which return QTextTable should not increment its reference
+ self.assertEqual(getrefcount(self.table), 2)
+ f = self.cursor.currentFrame()
+ del f
+ self.assertEqual(getrefcount(self.table), 2)
+ # destroying the cursor should not raise any "RuntimeError: internal
+ # C++ object already deleted." when accessing the QTextTable
+ del self.cursor
+ self.assertEqual(getrefcount(self.table), 2)
+ cell = self.table.cellAt(0, 0)
+
+if __name__ == "__main__":
+ unittest.main()