aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6')
-rw-r--r--sources/pyside6/tests/pysidetest/container_test.py20
-rw-r--r--sources/pyside6/tests/pysidetest/containertest.cpp20
-rw-r--r--sources/pyside6/tests/pysidetest/containertest.h8
3 files changed, 47 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()
-
diff --git a/sources/pyside6/tests/pysidetest/containertest.cpp b/sources/pyside6/tests/pysidetest/containertest.cpp
index ccb90b12f..9debfa5b7 100644
--- a/sources/pyside6/tests/pysidetest/containertest.cpp
+++ b/sources/pyside6/tests/pysidetest/containertest.cpp
@@ -60,3 +60,23 @@ QMultiHash<int, QString> ContainerTest::passThroughMultiHash(const QMultiHash<in
{
return in;
}
+
+QList<int> ContainerTest::createList()
+{
+ return {1, 2};
+}
+
+QList<int> ContainerTest::passThroughList(const QList<int> &list)
+{
+ return list;
+}
+
+QSet<int> ContainerTest::createSet()
+{
+ return {1, 2};
+}
+
+QSet<int> ContainerTest::passThroughSet(const QSet<int> &set)
+{
+ return set;
+}
diff --git a/sources/pyside6/tests/pysidetest/containertest.h b/sources/pyside6/tests/pysidetest/containertest.h
index 3405b6722..f214bdd40 100644
--- a/sources/pyside6/tests/pysidetest/containertest.h
+++ b/sources/pyside6/tests/pysidetest/containertest.h
@@ -31,9 +31,11 @@
#include "pysidetest_macros.h"
#include <QtCore/QObject>
+#include <QtCore/QList>
#include <QtCore/QMap>
#include <QtCore/QMultiMap>
#include <QtCore/QMultiHash>
+#include <QtCore/QSet>
#include <QtCore/QString>
class PYSIDETEST_API ContainerTest
@@ -48,4 +50,10 @@ public:
static QMultiHash<int, QString> createMultiHash();
static QMultiHash<int, QString> passThroughMultiHash(const QMultiHash<int, QString> &in);
+
+ static QList<int> createList();
+ static QList<int> passThroughList(const QList<int> &list);
+
+ static QSet<int> createSet();
+ static QSet<int> passThroughSet(const QSet<int> &set);
};