From bae4c2d9f1b249628797fe92dc7ec8c5bd98118a Mon Sep 17 00:00:00 2001 From: Michael Seifert Date: Fri, 11 Mar 2022 10:33:49 +0100 Subject: [PATCH] test: Ignore subprocess tests when running on CPython 3.7. When run with Python 3.7 asyncio.subprocess.create_subprocess_exec seems to be affected by an issue that prevents correct cleanup. Tests using pytest-trio will report that signal handling is already performed by another library and fail. [1] This is possibly a bug in CPython 3.7, so we ignore this test for that Python version. CPython 3.7 uses asyncio.streams.StreamReader and asyncio.streams.StreamWriter to implement asyncio.streams.StreamReaderProtocol and asyncio.subprocess.SubprocessStreamProtocol. StreamReaderProtocol contained cyclic references between the reader and the protocol, which prevented garbage collection. While StreamReaderProtocol received a patch [2], SubprocessStreamProtocol, which is used by create_subprocess_exec, possibly has the same problem, but was not patched as part of CPython 3.7. That's why we ignore this test for CPython 3.7. [1] https://github.com/python-trio/pytest-trio/issues/126 [2] https://github.com/python/cpython/pull/9201 Signed-off-by: Michael Seifert --- tests/test_subprocess.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/test_subprocess.py b/tests/test_subprocess.py index 8f1caee5..79c5109d 100644 --- a/tests/test_subprocess.py +++ b/tests/test_subprocess.py @@ -15,6 +15,18 @@ def event_loop(): loop.close() +@pytest.mark.skipif( + sys.version_info < (3, 8), + reason=""" + When run with Python 3.7 asyncio.subprocess.create_subprocess_exec seems to be + affected by an issue that prevents correct cleanup. Tests using pytest-trio + will report that signal handling is already performed by another library and + fail. [1] This is possibly a bug in CPython 3.7, so we ignore this test for + that Python version. + + [1] https://github.com/python-trio/pytest-trio/issues/126 + """, +) @pytest.mark.asyncio async def test_subprocess(event_loop): """Starting a subprocess should be possible."""