Create unit test for bug #835
Signed-off-by: Paulo Alcantara <paulo.alcantara@openbossa.org>
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Hugo Parente Lima <hugo.pl@gmail.com>
This commit is contained in:
parent
81d7107279
commit
595133f9c8
2 changed files with 66 additions and 0 deletions
|
|
@ -13,6 +13,7 @@ PYSIDE_TEST(bug_724.py)
|
||||||
PYSIDE_TEST(bug_820.py)
|
PYSIDE_TEST(bug_820.py)
|
||||||
PYSIDE_TEST(bug_826.py)
|
PYSIDE_TEST(bug_826.py)
|
||||||
PYSIDE_TEST(bug_829.py)
|
PYSIDE_TEST(bug_829.py)
|
||||||
|
PYSIDE_TEST(bug_835.py)
|
||||||
PYSIDE_TEST(blocking_signals_test.py)
|
PYSIDE_TEST(blocking_signals_test.py)
|
||||||
PYSIDE_TEST(child_event_test.py)
|
PYSIDE_TEST(child_event_test.py)
|
||||||
PYSIDE_TEST(deepcopy_test.py)
|
PYSIDE_TEST(deepcopy_test.py)
|
||||||
|
|
|
||||||
65
tests/QtCore/bug_835.py
Normal file
65
tests/QtCore/bug_835.py
Normal file
|
|
@ -0,0 +1,65 @@
|
||||||
|
from PySide.QtCore import *
|
||||||
|
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
get_counter = 0
|
||||||
|
set_counter = 0
|
||||||
|
|
||||||
|
class Descriptor(object):
|
||||||
|
def __get__(self, obj, owner):
|
||||||
|
global get_counter
|
||||||
|
|
||||||
|
if not obj:
|
||||||
|
return self
|
||||||
|
|
||||||
|
get_counter += 1
|
||||||
|
return obj.var
|
||||||
|
|
||||||
|
def __set__(self, obj, value):
|
||||||
|
global set_counter
|
||||||
|
|
||||||
|
set_counter += 1
|
||||||
|
obj.var = value
|
||||||
|
|
||||||
|
class FooBar(QObject):
|
||||||
|
test = Descriptor()
|
||||||
|
var = 0
|
||||||
|
|
||||||
|
class SetAndGetTestCases(unittest.TestCase):
|
||||||
|
def setUp(self):
|
||||||
|
global get_counter
|
||||||
|
global set_counter
|
||||||
|
|
||||||
|
get_counter = 0
|
||||||
|
set_counter = 0
|
||||||
|
|
||||||
|
def testSetMethod(self):
|
||||||
|
global get_counter
|
||||||
|
global set_counter
|
||||||
|
|
||||||
|
f = FooBar()
|
||||||
|
|
||||||
|
f.test = 1
|
||||||
|
self.assertEqual(get_counter, 0)
|
||||||
|
self.assertEqual(set_counter, 1)
|
||||||
|
|
||||||
|
get_counter = 0
|
||||||
|
set_counter = 0
|
||||||
|
|
||||||
|
def testGetMethod(self):
|
||||||
|
global get_counter
|
||||||
|
global set_counter
|
||||||
|
|
||||||
|
f = FooBar()
|
||||||
|
f.test = 1
|
||||||
|
set_counter = 0
|
||||||
|
|
||||||
|
ret = f.test
|
||||||
|
self.assertEqual(get_counter, 1)
|
||||||
|
self.assertEqual(set_counter, 0)
|
||||||
|
|
||||||
|
get_counter = 0
|
||||||
|
set_counter = 0
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
Loading…
Add table
Add a link
Reference in a new issue