Created new unittest model.
Separete unittest for module.
Only run unittest for compiled modules.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>,
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
471486732b
commit
ab918abc1e
211 changed files with 241 additions and 79 deletions
|
|
@ -1,52 +0,0 @@
|
|||
import unittest
|
||||
import sys
|
||||
|
||||
from helper import UsesQApplication
|
||||
from PySide.QtGui import QLayout, QWidget, QPushButton, QWidgetItem
|
||||
|
||||
class MyLayout(QLayout):
|
||||
def __init__(self, parent=None):
|
||||
QLayout.__init__(self, parent)
|
||||
self._list = []
|
||||
|
||||
def addItem(self, item):
|
||||
self.add(item)
|
||||
|
||||
def addWidget(self, widget):
|
||||
self.add(QWidgetItem(widget))
|
||||
|
||||
def itemAt(self, index):
|
||||
if index < len(self._list):
|
||||
return self._list[index]
|
||||
|
||||
return None
|
||||
|
||||
def count(self):
|
||||
return len(self._list)
|
||||
|
||||
def add(self, item):
|
||||
self._list.append(item)
|
||||
|
||||
|
||||
|
||||
#Test if a layout implemented in python, the QWidget.setLayout works
|
||||
#fine because this implement som layout functions used in glue code of
|
||||
#QWidget, then in c++ when call a virtual function this need call the QLayout
|
||||
#function implemented in python
|
||||
|
||||
class QLayoutTest(UsesQApplication):
|
||||
|
||||
def testOwnershipTransfer(self):
|
||||
b = QPushButton("teste")
|
||||
l = MyLayout()
|
||||
l.addWidget(b)
|
||||
|
||||
self.assertEqual(sys.getrefcount(b), 2)
|
||||
|
||||
w = QWidget()
|
||||
w.setLayout(l)
|
||||
|
||||
self.assertEqual(sys.getrefcount(b), 3)
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue