blob: db8783e986260ee15f289335331613b27875e2a9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
'''Test cases for QLabel->pixmap refcount control'''
import unittest
import sys
from helper import UsesQApplication
from PySide.QtGui import QApplication, QLabel, QPixmap
class QLabelTest(UsesQApplication):
'''Test case for constructor of QBrush'''
def testDestroyOwner(self):
p = QPixmap()
l = QLabel()
l.setPixmap(p)
del p
p1 = l.pixmap()
self.assertEqual(sys.getrefcount(p1), 2)
self.assertEqual(sys.getrefcount(l), 2)
del l
self.assertEqual(sys.getrefcount(p1), 2)
def testRefCount(self):
p = QPixmap()
l = QLabel()
l.setPixmap(p)
del p
p1 = l.pixmap()
self.assertEqual(sys.getrefcount(p1), 2)
p2 = l.pixmap()
self.assertEqual(sys.getrefcount(p2), 3)
p3 = l.pixmap()
self.assertEqual(sys.getrefcount(p3), 4)
if __name__ == '__main__':
unittest.main()
|