Created unit test for bug #811.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Marcelo Lira <marcelo.lira@openbossa.org>
This commit is contained in:
parent
6ad57fe3f4
commit
ef05a106c3
2 changed files with 33 additions and 0 deletions
|
|
@ -52,6 +52,7 @@ PYSIDE_TEST(bug_740.py)
|
||||||
PYSIDE_TEST(bug_743.py)
|
PYSIDE_TEST(bug_743.py)
|
||||||
PYSIDE_TEST(bug_750.py)
|
PYSIDE_TEST(bug_750.py)
|
||||||
PYSIDE_TEST(bug_793.py)
|
PYSIDE_TEST(bug_793.py)
|
||||||
|
PYSIDE_TEST(bug_811.py)
|
||||||
PYSIDE_TEST(customproxywidget_test.py)
|
PYSIDE_TEST(customproxywidget_test.py)
|
||||||
PYSIDE_TEST(deepcopy_test.py)
|
PYSIDE_TEST(deepcopy_test.py)
|
||||||
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
|
PYSIDE_TEST(float_to_int_implicit_conversion_test.py)
|
||||||
|
|
|
||||||
32
tests/QtGui/bug_811.py
Normal file
32
tests/QtGui/bug_811.py
Normal file
|
|
@ -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()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue