1818import pytest
1919
2020import qasync
21+ from qasync import QtModuleName
22+
23+ # flags for skipping certain tests for PySide6
24+ # This module has known issues causing crashes if certain
25+ # combinations of tests are invoked, likely caused by some internal problems.
26+ # current experimentation shows that it is sufficient to skip the socket pair
27+ # tests and the event-loop-on-qthread tests to avoid crashes later on in the suite.
28+ # Setting any one of these flags true reduces the frequency of crashes
29+ # but does not eliminate them.
30+ skip_process = False
31+ skip_socket = True
32+ skip_qthread = True
2133
2234
2335@pytest .fixture
@@ -65,6 +77,8 @@ def excepthook(type, *args):
6577)
6678def executor (request ):
6779 exc_cls = request .param
80+ if exc_cls is ProcessPoolExecutor and QtModuleName == "PySide6" and skip_process :
81+ pytest .skip ("subprocess is unreliable for PySide6" )
6882 if exc_cls is None :
6983 return None
7084
@@ -130,6 +144,7 @@ async def blocking_task(self, loop, executor, was_invoked):
130144 logging .debug ("start blocking task()" )
131145
132146
147+ @pytest .mark .skipif (QtModuleName == "PySide6" and skip_process , reason = "subprocess is unreliable on PySide6" )
133148def test_can_execute_subprocess (loop ):
134149 """Verify that a subprocess can be executed."""
135150
@@ -143,6 +158,7 @@ async def mycoro():
143158 loop .run_until_complete (asyncio .wait_for (mycoro (), timeout = 10.0 ))
144159
145160
161+ @pytest .mark .skipif (QtModuleName == "PySide6" and skip_process , reason = "subprocess is unreliable on PySide6" )
146162def test_can_read_subprocess (loop ):
147163 """Verify that a subprocess's data can be read from stdout."""
148164
@@ -163,6 +179,7 @@ async def mycoro():
163179 loop .run_until_complete (asyncio .wait_for (mycoro (), timeout = 10.0 ))
164180
165181
182+ @pytest .mark .skipif (QtModuleName == "PySide6" and skip_process , reason = "subprocess is unreliable on PySide6" )
166183def test_can_communicate_subprocess (loop ):
167184 """Verify that a subprocess's data can be passed in/out via stdin/stdout."""
168185
@@ -184,6 +201,7 @@ async def mycoro():
184201 loop .run_until_complete (asyncio .wait_for (mycoro (), timeout = 10.0 ))
185202
186203
204+ @pytest .mark .skipif (QtModuleName == "PySide6" and skip_process , reason = "subprocess is unreliable on PySide6" )
187205def test_can_terminate_subprocess (loop ):
188206 """Verify that a subprocess can be terminated."""
189207
@@ -309,6 +327,8 @@ def sock_pair(request):
309327
310328 If socket.socketpair isn't available, we emulate it.
311329 """
330+ if QtModuleName == "PySide6" and skip_socket :
331+ pytest .skip ("SocketPairs are unreliable on PySide6" )
312332
313333 def fin ():
314334 if client_sock is not None :
@@ -887,6 +907,7 @@ def test_run_forever_custom_exit_code(loop, application):
887907 application .exec_ = orig_exec
888908
889909
910+ @pytest .mark .skipif (QtModuleName == "PySide6" and skip_qthread , reason = "unreliable on PySide6" )
890911def test_qeventloop_in_qthread ():
891912 class CoroutineExecutorThread (qasync .QtCore .QThread ):
892913 def __init__ (self , coro ):
0 commit comments