aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui/bug_674.py
blob: 4b9ac193def5da472cab7ec405e9bf76b81e7c04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from PySide.QtCore import *
from PySide.QtGui import *
import unittest
import sys

class TestBug679(unittest.TestCase):
    '''QGraphicsScene::clear() is missing'''
    def testIt(self):
        app = QApplication([])

        scene = QGraphicsScene()
        hello = scene.addText("Hello")
        scene.addText("World")

        self.assertEqual(sys.getrefcount(hello), 3)
        scene.clear()
        self.assertEqual(sys.getrefcount(hello), 2)
        self.assertEqual(len(scene.items()), 0)
        self.assertRaises(RuntimeError, lambda: hello.isVisible) # the C++ object was deleted

if __name__ == '__main__':
    unittest.main()