~ubuntu-branches/ubuntu/natty/pyside/natty-proposed

« back to all changes in this revision

Viewing changes to tests/QtGui/bug_576.py

  • Committer: Bazaar Package Importer
  • Author(s): Didier Raboud
  • Date: 2011-02-18 18:01:00 UTC
  • mfrom: (1.2.3 upstream) (6.1.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20110218180100-vaczjij7g08fzfme
Tags: 1.0.0~rc1-1
* New 1.0.0~rc1 upstream release
  - Bump the B-D chain versions:
    + apiextractor to 0.10.0-2~
    + generatorrunner to 0.6.6
    + shiboken to 1.0.0~rc1
* Update patches to ~rc1.
* debian/watch: update to handle Release Candidates too.
* Bump XS-Python-Version to >= 2.6.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
""" Unittest for bug #576 """
 
2
""" http://bugs.openbossa.org/show_bug.cgi?id=576 """
 
3
 
 
4
from PySide import QtGui, QtCore
 
5
import sys
 
6
import unittest
 
7
 
 
8
class Bug576(unittest.TestCase):
 
9
    def onButtonDestroyed(self, button):
 
10
        self._destroyed = True
 
11
 
 
12
    def testWidgetParent(self):
 
13
        self._destroyed = False
 
14
        app = QtGui.QApplication(sys.argv)
 
15
        w = QtGui.QWidget()
 
16
 
 
17
        b = QtGui.QPushButton("test")
 
18
        b.destroyed[QtCore.QObject].connect(self.onButtonDestroyed)
 
19
        self.assertEqual(sys.getrefcount(b), 2)
 
20
        b.setParent(w)
 
21
        self.assertEqual(sys.getrefcount(b), 3)
 
22
        b.parent()
 
23
        self.assertEqual(sys.getrefcount(b), 3)
 
24
        b.setParent(None)
 
25
        self.assertEqual(sys.getrefcount(b), 2)
 
26
        del b
 
27
        self.assert_(self._destroyed)
 
28
 
 
29
 
 
30
if __name__ == '__main__':
 
31
    unittest.main()
 
32