aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/util
diff options
context:
space:
mode:
Diffstat (limited to 'sources/pyside6/tests/util')
-rw-r--r--sources/pyside6/tests/util/color.py36
-rw-r--r--sources/pyside6/tests/util/helper/basicpyslotcase.py34
-rw-r--r--sources/pyside6/tests/util/helper/docmodifier.py42
-rw-r--r--sources/pyside6/tests/util/helper/helper.py50
-rw-r--r--sources/pyside6/tests/util/helper/timedqapplication.py33
-rw-r--r--sources/pyside6/tests/util/helper/timedqguiapplication.py28
-rw-r--r--sources/pyside6/tests/util/helper/usesqapplication.py63
-rw-r--r--sources/pyside6/tests/util/helper/usesqcoreapplication.py59
-rw-r--r--sources/pyside6/tests/util/helper/usesqguiapplication.py49
-rw-r--r--sources/pyside6/tests/util/httpd.py37
-rw-r--r--sources/pyside6/tests/util/processtimer.py104
-rw-r--r--sources/pyside6/tests/util/pyqt_diff.py62
-rwxr-xr-xsources/pyside6/tests/util/rename_imports.sh30
-rw-r--r--sources/pyside6/tests/util/test_processtimer.py37
14 files changed, 167 insertions, 497 deletions
diff --git a/sources/pyside6/tests/util/color.py b/sources/pyside6/tests/util/color.py
index b2637dd90..fb91beac8 100644
--- a/sources/pyside6/tests/util/color.py
+++ b/sources/pyside6/tests/util/color.py
@@ -1,37 +1,13 @@
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
'''Function to print a colored line to terminal'''
-RED='\033[0;31m%s\033[m'
-def print_colored(message, color=RED):
- print(color % message)
+def print_colored(message):
+ print(f'\033[0;31m{message}\033[m') # red
+
if __name__ == '__main__':
print('42 - the answer')
diff --git a/sources/pyside6/tests/util/helper/basicpyslotcase.py b/sources/pyside6/tests/util/helper/basicpyslotcase.py
index 511db8e08..80da149bd 100644
--- a/sources/pyside6/tests/util/helper/basicpyslotcase.py
+++ b/sources/pyside6/tests/util/helper/basicpyslotcase.py
@@ -1,30 +1,8 @@
-#############################################################################
-##
-## Copyright (C) 2020 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
+
+import gc
class BasicPySlotCase(object):
@@ -40,6 +18,8 @@ class BasicPySlotCase(object):
del self.args
except:
pass
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
def cb(self, *args):
'''Simple callback with arbitrary arguments.
diff --git a/sources/pyside6/tests/util/helper/docmodifier.py b/sources/pyside6/tests/util/helper/docmodifier.py
index 5db344f62..b6de62abb 100644
--- a/sources/pyside6/tests/util/helper/docmodifier.py
+++ b/sources/pyside6/tests/util/helper/docmodifier.py
@@ -1,30 +1,6 @@
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
'''Helper metaclass do 'decorate' docstrings from base test case classes'''
@@ -108,9 +84,9 @@ if __name__ == '__main__':
doc_filter = lambda x: x.startswith('test')
doc_suffix = 'suffix'
- assert(Implementing.testBase.__doc__ == 'prefixbasesuffix')
- assert(Implementing.testWithoutDoc.__doc__ == None)
- assert(OnlySuffix.testBase.__doc__ == 'basesuffix')
- assert(OnlySuffix.testWithoutDoc.__doc__ == None)
- assert(OnlyPrefix.testBase.__doc__ == 'prefixbase')
- assert(OnlyPrefix.testWithoutDoc.__doc__ == None)
+ assert (Implementing.testBase.__doc__ == 'prefixbasesuffix')
+ assert (Implementing.testWithoutDoc.__doc__ == None)
+ assert (OnlySuffix.testBase.__doc__ == 'basesuffix')
+ assert (OnlySuffix.testWithoutDoc.__doc__ == None)
+ assert (OnlyPrefix.testBase.__doc__ == 'prefixbase')
+ assert (OnlyPrefix.testWithoutDoc.__doc__ == None)
diff --git a/sources/pyside6/tests/util/helper/helper.py b/sources/pyside6/tests/util/helper/helper.py
index f03a4e90c..ba742099e 100644
--- a/sources/pyside6/tests/util/helper/helper.py
+++ b/sources/pyside6/tests/util/helper/helper.py
@@ -1,30 +1,6 @@
-#############################################################################
-##
-## Copyright (C) 2020 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
'''Helper classes and functions'''
@@ -37,6 +13,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)]))
diff --git a/sources/pyside6/tests/util/helper/timedqapplication.py b/sources/pyside6/tests/util/helper/timedqapplication.py
index f172878ef..4984ad2c0 100644
--- a/sources/pyside6/tests/util/helper/timedqapplication.py
+++ b/sources/pyside6/tests/util/helper/timedqapplication.py
@@ -1,33 +1,10 @@
-#############################################################################
-##
-## Copyright (C) 2020 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
'''Helper classes and functions'''
+import gc
import unittest
from PySide6.QtCore import QTimer
@@ -47,3 +24,5 @@ class TimedQApplication(unittest.TestCase):
def tearDown(self):
'''Delete resources'''
del self.app
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
diff --git a/sources/pyside6/tests/util/helper/timedqguiapplication.py b/sources/pyside6/tests/util/helper/timedqguiapplication.py
new file mode 100644
index 000000000..86bc8df7d
--- /dev/null
+++ b/sources/pyside6/tests/util/helper/timedqguiapplication.py
@@ -0,0 +1,28 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
+
+'''Helper classes and functions'''
+
+import gc
+import unittest
+
+from PySide6.QtCore import QTimer
+from PySide6.QtGui import QGuiApplication
+
+
+class TimedQGuiApplication(unittest.TestCase):
+ '''Helper class with timed QGuiApplication exec loop'''
+
+ def setUp(self, timeout=100):
+ '''Sets up this Application.
+
+ timeout - timeout in millisseconds'''
+ self.app = QGuiApplication.instance() or QGuiApplication([])
+ QTimer.singleShot(timeout, self.app.quit)
+
+ def tearDown(self):
+ '''Delete resources'''
+ del self.app
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
diff --git a/sources/pyside6/tests/util/helper/usesqapplication.py b/sources/pyside6/tests/util/helper/usesqapplication.py
index abb2ca238..44723d392 100644
--- a/sources/pyside6/tests/util/helper/usesqapplication.py
+++ b/sources/pyside6/tests/util/helper/usesqapplication.py
@@ -1,51 +1,44 @@
-#############################################################################
-##
-## Copyright (C) 2020 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
'''Helper classes and functions'''
+import gc
+import sys
import unittest
-from PySide6.QtWidgets import QApplication
+# This version avoids explicit import in order to adapt to the
+# import decision of the main module.
+# This should work with every compatible library.
+# Replaces the QtGui and QtCore versions as well.
class UsesQApplication(unittest.TestCase):
- '''Helper class to provide QApplication instances'''
-
- qapplication = True
+ '''Helper class to provide Q(Core|Gui|)Application instances
+ Just connect or call self.exit_app_cb. When called, will ask
+ self.app to exit.
+ '''
def setUp(self):
'''Creates the QApplication instance'''
-
+ module = sys.modules[sorted(_ for _ in sys.modules
+ if _.endswith((".QtCore", ".QtGui", ".QtWidgets")))[-1]]
+ found = module.__name__.rsplit(".")[-1]
+ cls = getattr(module, {"QtWidgets": "QApplication",
+ "QtGui": "QGuiApplication",
+ "QtCore": "QCoreApplication"}[found])
# Simple way of making instance a singleton
- super(UsesQApplication, self).setUp()
- self.app = QApplication.instance() or QApplication([])
+ super().setUp()
+ self.app = cls.instance() or cls([])
def tearDown(self):
'''Deletes the reference owned by self'''
del self.app
- super(UsesQApplication, self).tearDown()
+ # PYSIDE-535: Need to collect garbage in PyPy to trigger deletion
+ gc.collect()
+ super().tearDown()
+
+ def exit_app_cb(self):
+ '''Quits the application'''
+ self.app.exit(0)
diff --git a/sources/pyside6/tests/util/helper/usesqcoreapplication.py b/sources/pyside6/tests/util/helper/usesqcoreapplication.py
deleted file mode 100644
index 9f4a4280d..000000000
--- a/sources/pyside6/tests/util/helper/usesqcoreapplication.py
+++ /dev/null
@@ -1,59 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2020 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-'''Helper classes and functions'''
-
-import unittest
-
-from PySide6.QtCore import QCoreApplication
-
-_core_instance = None
-
-
-class UsesQCoreApplication(unittest.TestCase):
- '''Helper class for test cases that require an QCoreApplication
- Just connect or call self.exit_app_cb. When called, will ask
- self.app to exit.
- '''
-
- def setUp(self):
- '''Set up resources'''
-
- global _core_instance
- if _core_instance is None:
- _core_instance = QCoreApplication([])
-
- self.app = _core_instance
-
- def tearDown(self):
- '''Release resources'''
- del self.app
-
- def exit_app_cb(self):
- '''Quits the application'''
- self.app.exit(0)
diff --git a/sources/pyside6/tests/util/helper/usesqguiapplication.py b/sources/pyside6/tests/util/helper/usesqguiapplication.py
deleted file mode 100644
index 65c4f4939..000000000
--- a/sources/pyside6/tests/util/helper/usesqguiapplication.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2020 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-'''Helper classes and functions'''
-
-import unittest
-
-from PySide6.QtGui import QGuiApplication
-
-
-class UsesQGuiApplication(unittest.TestCase):
- '''Helper class to provide QGuiApplication instances'''
-
- def setUp(self):
- '''Creates the QGuiApplication instance'''
-
- # Simple way of making instance a singleton
- super(UsesQGuiApplication, self).setUp()
- self.app = QGuiApplication.instance() or QGuiApplication([])
-
- def tearDown(self):
- '''Deletes the reference owned by self'''
- del self.app
- super(UsesQGuiApplication, self).tearDown()
diff --git a/sources/pyside6/tests/util/httpd.py b/sources/pyside6/tests/util/httpd.py
index 82bec337d..9141c191c 100644
--- a/sources/pyside6/tests/util/httpd.py
+++ b/sources/pyside6/tests/util/httpd.py
@@ -1,30 +1,6 @@
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
import http.server as BaseHTTPServer
import os
@@ -39,7 +15,7 @@ sys.path.append(os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__f
class TestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
- DATA = "PySide Server"
+ DATA = b"PySide Server"
allow_reuse_address = True
def do_GET(self):
@@ -55,6 +31,7 @@ class TestHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.send_header("Content-Length", str(len(TestHandler.DATA)))
self.end_headers()
+
class TestSecureHandler(BaseHTTPServer.BaseHTTPRequestHandler):
DATA = "PySide"
allow_reuse_address = True
@@ -78,6 +55,8 @@ class TestSecureHandler(BaseHTTPServer.BaseHTTPRequestHandler):
self.end_headers()
# Workaround for the missing shutdown method in python2.5
+
+
class CompatTCPServer(SocketServer.TCPServer):
def __init__(self, server_address, RequestHandlerClass):
SocketServer.TCPServer.__init__(self, server_address, RequestHandlerClass)
@@ -158,7 +137,7 @@ class TestServer(threading.Thread):
while True:
try:
- self.httpd = CompatTCPServer(('' , self._port), handle)
+ self.httpd = CompatTCPServer(('', self._port), handle)
break
except:
self._port = self._port + random.randint(1, 100)
diff --git a/sources/pyside6/tests/util/processtimer.py b/sources/pyside6/tests/util/processtimer.py
index 067f1d29c..8187901c6 100644
--- a/sources/pyside6/tests/util/processtimer.py
+++ b/sources/pyside6/tests/util/processtimer.py
@@ -1,77 +1,55 @@
#!/usr/bin/env python
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+import os
+import time
-import time,os
class TimeoutException(Exception):
- def __init__(self, msg):
- self.msg = msg
+ def __init__(self, msg):
+ self.msg = msg
- def __str__(self):
- return repr(self.msg)
+ def __str__(self):
+ return repr(self.msg)
-class ProcessTimer(object):
- '''Timeout function for controlling a subprocess.Popen instance.
- Naive implementation using busy loop, see later other means
- of doing this.
- '''
+class ProcessTimer(object):
+ '''Timeout function for controlling a subprocess.Popen instance.
- def __init__(self, proc, timeout):
- self.proc = proc
- self.timeout = timeout
+ Naive implementation using busy loop, see later other means
+ of doing this.
+ '''
- def waitfor(self):
- time_passed = 0
- while(self.proc.poll() is None and time_passed < self.timeout):
- time_passed = time_passed + 1
- time.sleep(1)
+ def __init__(self, proc, timeout):
+ self.proc = proc
+ self.timeout = timeout
- if time_passed >= self.timeout:
- raise TimeoutException("Timeout expired, possible deadlock")
+ def waitfor(self):
+ time_passed = 0
+ while (self.proc.poll() is None and time_passed < self.timeout):
+ time_passed = time_passed + 1
+ time.sleep(1)
-if __name__ == "__main__":
- #simple example
+ if time_passed >= self.timeout:
+ raise TimeoutException("Timeout expired, possible deadlock")
- from subprocess import Popen
-
- proc = Popen(['sleep','10'])
- t = ProcessTimer(proc,5)
- try:
- t.waitfor()
- except TimeoutException:
- print(f"timeout - PID: {t.proc.pid}")
- #TODO: detect SO and kill accordingly
- #Linux
- os.kill(t.proc.pid, 9)
- #Windows (not tested)
- #subprocess.Popen("taskkill /F /T /PID %i"%handle.pid , shell=True)
- print(f"exit code: {t.proc.poll()}")
+if __name__ == "__main__":
+ # simple example
+
+ from subprocess import Popen
+
+ proc = Popen(['sleep', '10'])
+ t = ProcessTimer(proc, 5)
+ try:
+ t.waitfor()
+ except TimeoutException:
+ print(f"timeout - PID: {t.proc.pid}")
+ #TODO: detect SO and kill accordingly
+ #Linux
+ os.kill(t.proc.pid, 9)
+ #Windows (not tested)
+ #subprocess.Popen("taskkill /F /T /PID %i"%handle.pid , shell=True)
+ print(f"exit code: {t.proc.poll()}")
diff --git a/sources/pyside6/tests/util/pyqt_diff.py b/sources/pyside6/tests/util/pyqt_diff.py
deleted file mode 100644
index 380fd08e0..000000000
--- a/sources/pyside6/tests/util/pyqt_diff.py
+++ /dev/null
@@ -1,62 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-'''Script to show the difference between PyQt5 and ours'''
-
-import sys
-
-from color import print_colored
-
-def check_module_diff(module_name):
- '''Difference between PySide6 and PyQt5 versions of qt bindings.
- Returns a tuple with the members present only on PySide6 and only on PyQt5'''
- shiboken_module = getattr(__import__('PySide6.' + module_name), module_name)
- orig_module = getattr(__import__('PyQt5.' + module_name), module_name)
-
- shiboken_set = set(dir(shiboken_module))
- orig_set = set(dir(orig_module))
-
- return sorted(shiboken_set - orig_set), sorted(orig_set - shiboken_set)
-
-
-def main(argv=None):
- if argv is None:
- argv = sys.argv
-
- module_name = argv[1] if len(argv) >= 2 else 'QtCore'
-
- only_shiboken, only_orig = check_module_diff(module_name)
-
- print_colored('Only on Shiboken version')
- print(only_shiboken)
-
- print_colored('Only on SIP version')
- print(only_orig)
-
-if __name__ == '__main__':
- main()
diff --git a/sources/pyside6/tests/util/rename_imports.sh b/sources/pyside6/tests/util/rename_imports.sh
index 64b1123ef..1ec900cb3 100755
--- a/sources/pyside6/tests/util/rename_imports.sh
+++ b/sources/pyside6/tests/util/rename_imports.sh
@@ -1,32 +1,6 @@
#!/bin/bash
-
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
# Rename import statements from .py script to use a specific module name
set -e
diff --git a/sources/pyside6/tests/util/test_processtimer.py b/sources/pyside6/tests/util/test_processtimer.py
index ba3e99775..417db8bec 100644
--- a/sources/pyside6/tests/util/test_processtimer.py
+++ b/sources/pyside6/tests/util/test_processtimer.py
@@ -1,30 +1,6 @@
-#############################################################################
-##
-## Copyright (C) 2016 The Qt Company Ltd.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is part of the test suite of Qt for Python.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+from __future__ import annotations
'Tests for processtimer.py'
@@ -34,6 +10,7 @@ import os
from subprocess import Popen, PIPE
from processtimer import TimeoutException, ProcessTimer
+
class TimeoutTest(unittest.TestCase):
def tearDown(self):
@@ -43,10 +20,11 @@ class TimeoutTest(unittest.TestCase):
pass
def testRaise(self):
- self.proc = Popen(['python2.5', '-c', 'while True: pass' ], stdout=PIPE, stderr=PIPE)
+ self.proc = Popen(['python2.5', '-c', 'while True: pass'], stdout=PIPE, stderr=PIPE)
timer = ProcessTimer(self.proc, 1)
self.assertRaises(TimeoutException, timer.waitfor)
+
class SimpleTest(unittest.TestCase):
def tearDown(self):
@@ -54,11 +32,13 @@ class SimpleTest(unittest.TestCase):
os.kill(self.proc.pid, 9)
except OSError:
pass
+
def testSimple(self):
self.proc = Popen(['python2.5', '-c', '"print"'], stdout=PIPE, stderr=PIPE)
timer = ProcessTimer(self.proc, 10)
timer.waitfor()
+
class TestEchoOutput(unittest.TestCase):
def tearDown(self):
@@ -73,6 +53,7 @@ class TestEchoOutput(unittest.TestCase):
timer.waitfor()
self.assertEqual(self.proc.stdout.read().strip(), '1')
+
class TestRetCode(unittest.TestCase):
def tearDown(self):