diff options
| author | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-05 09:14:53 +0100 |
|---|---|---|
| committer | Friedemann Kleint <Friedemann.Kleint@qt.io> | 2021-11-05 11:49:54 +0100 |
| commit | 391e47893c463da5b91024508b739e51ecdaaf45 (patch) | |
| tree | 755dc6b346bd175eeb504cbdd917ec3ef954b43e /sources/pyside6/tests/pysidetest/container_test.py | |
| parent | d8cd97b050c68f352fef1df375c5c98f1daae029 (diff) | |
shiboken6: Handle PySets as function parameters
Python sets are iterable but not of sequence type.
While the existing converter code from the templates uses iterators,
the built-in check functions
convertibleSequenceTypes()/checkSequenceTypes() assume a PySequence
and would fail for PySets.
Add new check functions convertibleIterableTypes()/checkIterableTypes()
using iterators and use them for PySet.
Add a test and a test for lists as a drive-by.
[ChangeLog][PySide6] sets are now supported for functions taking a QSet.
Pick-to: 6.2
Task-number: PYSIDE-174
Task-number: PYSIDE-1666
Change-Id: I883869162e7dfa9cd0e1669f941fb7864f0cf825
Reviewed-by: Christian Tismer <tismer@stackless.com>
Diffstat (limited to 'sources/pyside6/tests/pysidetest/container_test.py')
| -rw-r--r-- | sources/pyside6/tests/pysidetest/container_test.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sources/pyside6/tests/pysidetest/container_test.py b/sources/pyside6/tests/pysidetest/container_test.py index 14feb4465..1b5a94f31 100644 --- a/sources/pyside6/tests/pysidetest/container_test.py +++ b/sources/pyside6/tests/pysidetest/container_test.py @@ -45,6 +45,9 @@ EXPECTED_DICT = {1: ["v1"], 2: ["v2_1", "v2_2"], 4: ["v4_1", "v4_2"]} +EXPECTED_LIST = [1, 2] + + def sort_values(m): """Sort value lists in dicts since passing through a QMultiMap changes the order""" result = {} @@ -67,7 +70,22 @@ class ContainerTestTest(unittest.TestCase): m2 = ContainerTest.passThroughMultiHash(m1) self.assertEqual(sort_values(m2), EXPECTED_DICT) + def testList(self): + l1 = ContainerTest.createList(); + self.assertEqual(l1, EXPECTED_LIST) + l2 = ContainerTest.passThroughList(l1) + self.assertEqual(l2, EXPECTED_LIST) + + def testSet(self): + # FIXME PYSIDE 7: A PySet should be returned from QSet (currently PyList) + s1 = set(ContainerTest.createSet()); # Order is not predictable + s2 = set(ContainerTest.passThroughSet(s1)) + self.assertEqual(sorted(list(s1)), sorted(list(s2))) + + # Since lists are iterable, it should be possible to pass them to set API + l2 = ContainerTest.passThroughSet(EXPECTED_LIST) + self.assertEqual(sorted(l2), EXPECTED_LIST) + if __name__ == '__main__': unittest.main() - |
