diff options
| author | Adrian Herrmann <adrian.herrmann@qt.io> | 2024-02-28 15:41:37 +0100 |
|---|---|---|
| committer | Adrian Herrmann <adrian.herrmann@qt.io> | 2024-03-13 09:23:32 +0100 |
| commit | ef7bb87eee9bd4469ad858f7ca15f190dbc4aaf9 (patch) | |
| tree | 7894a256691164ebd0409093ba6728c1e16da989 /sources/pyside6/tests | |
| parent | 52d7a31d05b1cab5780d2eb050100c3433a5fc11 (diff) | |
Add QIOPipe
Add an implementation for a QIODevice that can be used to work with
anonymous pipes. It needs to be able to emit the bytesWritten and
readyRead signals. This implementation is lifted from the qt5 source
tree (qtdeclarative/tests/auto/qmlls/lifecycle) and might be added to
Qt in the future, at which point it will be removed from the PySide
source tree.
Change-Id: Iff1208a366dad747352e7507da0818934c26aa4f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'sources/pyside6/tests')
| -rw-r--r-- | sources/pyside6/tests/QtCore/qiopipe_test.py | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtCore/qiopipe_test.py b/sources/pyside6/tests/QtCore/qiopipe_test.py new file mode 100644 index 000000000..53a6ba70a --- /dev/null +++ b/sources/pyside6/tests/QtCore/qiopipe_test.py @@ -0,0 +1,36 @@ +# Copyright (C) 2024 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 + +'''Test cases for the QIOPipe class''' + +from PySide6.QtCore import QIODevice, QIOPipe + +import unittest + + +class QIOPipeTest(unittest.TestCase): + def setUp(self) -> None: + self.pipe = QIOPipe() + self.pipe.open(QIODevice.OpenModeFlag.ReadWrite) + return super().setUp() + + def tearDown(self) -> None: + super().tearDown() + + def ready_read_bytes_written(self): + received_data = self.pipe.end2().readAll().data() + self.assertEqual(received_data, self.data) + + def test_readyRead(self): + self.data = b"Hello, World!" + self.pipe.end2().readyRead.connect(self.ready_read_bytes_written) + self.pipe.end1().write(self.data) + + def test_bytesWritten(self): + self.data = b"Hello, World!" + self.pipe.end2().bytesWritten.connect(self.ready_read_bytes_written) + self.pipe.end1().write(self.data) + + +if __name__ == '__main__': + unittest.main() |
