aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/pysidetest/enum_test.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2025-07-24 12:38:39 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2025-07-28 11:33:24 +0200
commit84d0234d62ae2500707e2e48e9edccbd5a918e5b (patch)
tree403cb9d17bb61c044904411bd12ae5ba767957bc /sources/pyside6/tests/pysidetest/enum_test.py
parentb346dbda0f7b83ef4a17461418ddc74aaacd1dad (diff)
Enumerations: Enable the forgiveness feature ENOPT_NO_ZERODEFAULT for 3.14
Adapt the op codes for detecting a parameterless __init__() call in enum code to 3.14. Pick-to: 6.9 6.8 Task-number: PYSIDE-3147 Task-number: PYSIDE-1735 Change-Id: I7dcaaae82b4c136db5dbd9ef36519783b73c15ce Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests/pysidetest/enum_test.py')
-rw-r--r--sources/pyside6/tests/pysidetest/enum_test.py29
1 files changed, 26 insertions, 3 deletions
diff --git a/sources/pyside6/tests/pysidetest/enum_test.py b/sources/pyside6/tests/pysidetest/enum_test.py
index 908bdb151..ab20cbab4 100644
--- a/sources/pyside6/tests/pysidetest/enum_test.py
+++ b/sources/pyside6/tests/pysidetest/enum_test.py
@@ -49,8 +49,12 @@ class ListConnectionTest(unittest.TestCase):
# PYSIDE-1735: We are testing that opcodes do what they are supposed to do.
-# This is needed in the PyEnum forgiveness mode where we need
-# to introspect the code if an Enum was called with no args.
+# This is needed in the PyEnum forgiveness mode (ENOPT_NO_ZERODEFAULT)
+# where we need to introspect the code if an Enum was called with no args,
+# enabling default construction like 'f = Qt.WindowFlags()'.
+# Adapt for each Python version by checking the defines in the generated header opcode_ids.h
+# egrep '( RESUME | LOAD_GLOBAL | LOAD_ATTR | PUSH_NULL | CALL | STORE_FAST | RETURN_CONST )' opcode_ids.h
+# See also sbkfeature_base.cpp
# flake8: noqa
class InvestigateOpcodesTest(unittest.TestCase):
@@ -170,7 +174,7 @@ class InvestigateOpcodesTest(unittest.TestCase):
('STORE_FAST', 125, 1),
('RETURN_CONST', 121, 0)]
- if sys.version_info[:2] >= (3, 13):
+ if sys.version_info[:2] == (3, 13):
result_1 = [('RESUME', 149, 0),
('LOAD_GLOBAL', 91, 0),
@@ -186,6 +190,25 @@ class InvestigateOpcodesTest(unittest.TestCase):
('STORE_FAST', 110, 1),
('RETURN_CONST', 103, 0)]
+ if sys.version_info[:2] >= (3, 14):
+
+ result_1 = [('RESUME', 128, 0),
+ ('LOAD_GLOBAL', 92, 0),
+ ('LOAD_ATTR', 80, 2),
+ ('STORE_FAST', 112, 1),
+ ('LOAD_CONST', 82, 0),
+ ('RETURN_VALUE', 35, None)
+ ]
+
+ result_2 = [('RESUME', 128, 0),
+ ('LOAD_GLOBAL', 92, 0),
+ ('LOAD_ATTR', 80, 2),
+ ('PUSH_NULL', 33, None),
+ ('CALL', 52, 0),
+ ('STORE_FAST', 112, 1),
+ ('LOAD_CONST', 82, 0),
+ ('RETURN_VALUE', 35, None)]
+
self.assertEqual(self.read_code(self.probe_function1), result_1)
self.assertEqual(self.read_code(self.probe_function2), result_2)