aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/util/helper/helper.py
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-06 11:14:25 +0200
committerFriedemann Kleint <Friedemann.Kleint@qt.io>2021-04-06 15:29:32 +0200
commit04d45f0429c6c6d8eae9c4fcf269ffbcc7d074d8 (patch)
tree8ad179ccdec7bd45042e15619542b704eac3e867 /sources/pyside6/tests/util/helper/helper.py
parent27bb3f7839d9673b125f8b1b775c4398293932e2 (diff)
Port tests to pathlib
Replace test helper function adjust_filename() by pathlib handling. Add asserts on the existence everywhere. Add error handling with helper functions to QML loading, printing the error message in the assert statements. Task-number: PYSIDE-1499 Task-number: PYSIDE-1532 Change-Id: I206929effb37f21d1f621be921bb996162398b4d Reviewed-by: Christian Tismer <tismer@stackless.com> Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Diffstat (limited to 'sources/pyside6/tests/util/helper/helper.py')
-rw-r--r--sources/pyside6/tests/util/helper/helper.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/sources/pyside6/tests/util/helper/helper.py b/sources/pyside6/tests/util/helper/helper.py
index f03a4e90c..f500e3fa9 100644
--- a/sources/pyside6/tests/util/helper/helper.py
+++ b/sources/pyside6/tests/util/helper/helper.py
@@ -37,6 +37,26 @@ def adjust_filename(filename, orig_mod_filename):
return os.path.join(dirpath, filename)
+def _join_qml_errors(errors):
+ '''Return an error string from a list of QQmlError'''
+ result = ''
+ for i, error in enumerate(errors):
+ if i:
+ result += ', '
+ result += error.toString()
+ return result
+
+
+def quickview_errorstring(quickview):
+ '''Return an error string from a QQuickView'''
+ return _join_qml_errors(quickview.errors())
+
+
+def qmlcomponent_errorstring(component):
+ '''Return an error string from a QQmlComponent'''
+ return _join_qml_errors(component.errors())
+
+
def random_string(size=5):
'''Generate random string with the given size'''
return ''.join(map(chr, [randint(33, 126) for x in range(size)]))