aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorRenato Filho <renato.filho@openbossa.org>2011-04-19 13:39:04 -0300
committerHugo Parente Lima <hugo.pl@gmail.com>2012-03-08 16:54:13 -0300
commitef05a106c3733a7546dc918eaa9884e1e229f80a (patch)
tree4e90b74a204c581dd0e8317430f6ccbc52b98740 /tests
parent6ad57fe3f465ee4d878425d9147270ee36a75b52 (diff)
Created unit test for bug #811.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org> Marcelo Lira <marcelo.lira@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/QtGui/CMakeLists.txt1
-rw-r--r--tests/QtGui/bug_811.py32
2 files changed, 33 insertions, 0 deletions
diff --git a/tests/QtGui/CMakeLists.txt b/tests/QtGui/CMakeLists.txt
index 0c5b31e04..1dd2a23b4 100644
--- a/tests/QtGui/CMakeLists.txt
+++ b/tests/QtGui/CMakeLists.txt
@@ -52,6 +52,7 @@ PYSIDE_TEST(bug_740.py)
PYSIDE_TEST(bug_743.py)
PYSIDE_TEST(bug_750.py)
PYSIDE_TEST(bug_793.py)
+PYSIDE_TEST(bug_811.py)
PYSIDE_TEST(customproxywidget_test.py)
PYSIDE_TEST(deepcopy_test.py)
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
diff --git a/tests/QtGui/bug_811.py b/tests/QtGui/bug_811.py
new file mode 100644
index 000000000..af693bd27
--- /dev/null
+++ b/tests/QtGui/bug_811.py
@@ -0,0 +1,32 @@
+import unittest
+import sys
+import weakref
+
+from helper import UsesQApplication
+
+from PySide.QtGui import QTextBlockUserData, QTextEdit, QTextCursor
+
+class TestUserData(QTextBlockUserData):
+ def __init__(self, data):
+ super(TestUserData, self).__init__()
+ self.data = data
+
+class TestUserDataRefCount(UsesQApplication):
+ def testRefcount(self):
+ textedit = QTextEdit()
+ textedit.setReadOnly(True)
+ doc = textedit.document()
+ cursor = QTextCursor(doc)
+ cursor.insertText("PySide Rocks")
+ ud = TestUserData({"Life": 42})
+ self.assertEqual(sys.getrefcount(ud), 2)
+ cursor.block().setUserData(ud)
+ self.assertEqual(sys.getrefcount(ud), 3)
+ ud2 = cursor.block().userData()
+ self.assertEqual(sys.getrefcount(ud), 4)
+ self.udata = weakref.ref(ud, None)
+ del ud, ud2
+ self.assertEqual(sys.getrefcount(self.udata()), 2)
+
+if __name__ == '__main__':
+ unittest.main()