aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui/bug_714.py
blob: 937ff82bebc9f734c4be426321e670718bee86ee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import unittest
import sys
from PySide.QtGui import QLabel, QApplication, QPixmap

class TestLabelPixmap(unittest.TestCase):
    def testReference(self):
        l = QLabel()
        p = QPixmap()
        l.setPixmap(p) # doesn't increment pixmap ref because this makes a copy
        self.assertEqual(sys.getrefcount(p), 2)

        p = l.pixmap() # this increment the reference because this is an internal pointer
        self.assertEqual(sys.getrefcount(p), 3)

        p2 = l.pixmap()
        self.assertEqual(p, p2)

if __name__ == '__main__':
    app = QApplication([])
    unittest.main()