aboutsummaryrefslogtreecommitdiffstats
path: root/sources/pyside6/tests/QtCore/bug_686.py
diff options
context:
space:
mode:
authorChristian Tismer <tismer@stackless.com>2022-01-26 19:03:41 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-02-03 17:18:10 +0000
commit1daed708ee14d56717c374cca9c780e5d32acb0f (patch)
tree87a675e6b4bd19d79f9658a27f9f572d462d84dc /sources/pyside6/tests/QtCore/bug_686.py
parentdf8b9a68a98ac6045981e1d106acf31baea3668b (diff)
PyPySide: Fix locker handling which enables Mandelbrot
Not only the QPainter, but also the QMutexLocker were not correctly modelled after PEP 343 in the examples. Since that is now fixed, we consider the PyPy project not as ready, but good enough to publish it. It also turned out that people have the expectation to use QSignalBlocker in the "as" form: with QSignalBlocker(self.double_spin_box) as blocker: self.double_spin_box.setValue(2.5) https://stackoverflow.com/questions/60384734/how-to-use-qsignalblocker-in-python But that blocker would be None. As a side effect, QMutexLocker, QReadLocker, QWriteLocker and QSignalBlocker were augmented with a default __enter__ implementation that returns the locker instance. [ChangeLog][PySide6] The Mandelbrot example needed context managers for QPainter and QMutexLocker to work in PyPy. Task-number: PYSIDE-535 Change-Id: I2a62ca645a4fddcafbf11869f14a538141f32c39 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> (cherry picked from commit bc11e3c074bdba1ae0fcaa0c10e3b32f781be9fd) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'sources/pyside6/tests/QtCore/bug_686.py')
-rw-r--r--sources/pyside6/tests/QtCore/bug_686.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/sources/pyside6/tests/QtCore/bug_686.py b/sources/pyside6/tests/QtCore/bug_686.py
index 6e78e7f80..2437d101e 100644
--- a/sources/pyside6/tests/QtCore/bug_686.py
+++ b/sources/pyside6/tests/QtCore/bug_686.py
@@ -125,6 +125,19 @@ class TestQMutex (unittest.TestCase):
self.assertTrue(thread.wait(2000))
self.assertTrue(thread.canQuit)
+ def testWithAsLocker(self):
+ lock = QReadWriteLock()
+ with QReadLocker(lock) as locker:
+ self.assertTrue(isinstance(locker, QReadLocker))
+ with QWriteLocker(lock) as locker:
+ self.assertTrue(isinstance(locker, QWriteLocker))
+ mutex = QMutex()
+ with QMutexLocker(mutex) as locker:
+ self.assertTrue(isinstance(locker, QMutexLocker))
+ with self.assertRaises(TypeError):
+ with QMutexLocker(lock) as locker:
+ pass
+
if __name__ == '__main__':
unittest.main()