aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside2/tests
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2020-10-14 09:59:10 +0200
committerChristian Tismer <tismer@stackless.com>2020-10-27 13:13:46 +0000
commitdb03fa66435949c4c75658bbdfdaacbeedfa0413 (patch)
tree5c94ce063981982c7a50b3b190e758f202b063a3 /sources/pyside2/tests
parent1d044f467070a040713c9566a8a8de3a56c571e7 (diff)
feature-select: implement class properties
After implementing property objects for PySide, the static properties (properties for static functions) were quite missing, for instance from QtCore.QCoreApplication and QtWidgets.QApplication . This implementation uses the normal Python properties and derives a PySide.ClassProperty class which works almost the same on classes. The static methods had to be mutated to class methods explicitly. That would be automated by PyType_Ready, but here we are doing this after class initialization. Task-number: PYSIDE-1019 Change-Id: Iabe00be18e25881cc7a97507b6fdae3e2d57ff7a Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside2/tests')
-rw-r--r--sources/pyside2/tests/QtCore/snake_prop_feature_test.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/sources/pyside2/tests/QtCore/snake_prop_feature_test.py b/sources/pyside2/tests/QtCore/snake_prop_feature_test.py
index 779b8a408..b53a1f0a5 100644
--- a/sources/pyside2/tests/QtCore/snake_prop_feature_test.py
+++ b/sources/pyside2/tests/QtCore/snake_prop_feature_test.py
@@ -54,7 +54,7 @@ snake_prop_feature_test.py
Test the snake_case and true_property feature.
-This works now. More tests needed!
+This works now, including class properties.
"""
class Window(QtWidgets.QWidget):
@@ -68,6 +68,7 @@ class FeatureTest(unittest.TestCase):
__feature__.set_selection(0)
def tearDown(self):
+ __feature__.set_selection(0)
qApp.shutdown()
def testRenamedFunctions(self):
@@ -101,6 +102,22 @@ class FeatureTest(unittest.TestCase):
with self.assertRaises(AttributeError):
window.modal
+ def testClassProperty(self):
+ from __feature__ import snake_case, true_property
+ # We check the class...
+ self.assertEqual(type(QtWidgets.QApplication.quit_on_last_window_closed), bool)
+ x = QtWidgets.QApplication.quit_on_last_window_closed
+ QtWidgets.QApplication.quit_on_last_window_closed = not x
+ self.assertEqual(QtWidgets.QApplication.quit_on_last_window_closed, not x)
+ # ... and now the instance.
+ self.assertEqual(type(qApp.quit_on_last_window_closed), bool)
+ x = qApp.quit_on_last_window_closed
+ qApp.quit_on_last_window_closed = not x
+ self.assertEqual(qApp.quit_on_last_window_closed, not x)
+ # make sure values are equal
+ self.assertEqual(qApp.quit_on_last_window_closed,
+ QtWidgets.QApplication.quit_on_last_window_closed)
+
if __name__ == '__main__':
unittest.main()