forked from pool/python-pexpect
Compare commits
4 Commits
| Author | SHA256 | Date | |
|---|---|---|---|
| be025ced08 | |||
| a3bbb9c080 | |||
| e305d82cc2 | |||
| 870db12df1 |
104
py314.patch
Normal file
104
py314.patch
Normal file
@@ -0,0 +1,104 @@
|
||||
From 456bc10d94b57e254568e7ea9a8b3cffb856ebff Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
|
||||
Date: Fri, 22 Nov 2024 16:41:55 +0100
|
||||
Subject: [PATCH] Tests: Avoid the multiprocessing forkserver method
|
||||
|
||||
Fixes https://github.com/pexpect/pexpect/issues/807
|
||||
---
|
||||
tests/test_expect.py | 12 ++++++++++--
|
||||
tests/test_socket.py | 24 ++++++++++++++++--------
|
||||
2 files changed, 26 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/tests/test_expect.py b/tests/test_expect.py
|
||||
index c16e0551..fb1e30e2 100755
|
||||
--- a/tests/test_expect.py
|
||||
+++ b/tests/test_expect.py
|
||||
@@ -33,6 +33,14 @@
|
||||
|
||||
PY3 = bool(sys.version_info.major >= 3)
|
||||
|
||||
+# Python 3.14 changed the non-macOS POSIX default to forkserver
|
||||
+# but the code in this module does not work with it
|
||||
+# See https://github.com/python/cpython/issues/125714
|
||||
+if multiprocessing.get_start_method() == 'forkserver':
|
||||
+ mp_context = multiprocessing.get_context(method='fork')
|
||||
+else:
|
||||
+ mp_context = multiprocessing.get_context()
|
||||
+
|
||||
# Many of these test cases blindly assume that sequential directory
|
||||
# listings of the /bin directory will yield the same results.
|
||||
# This may not be true, but seems adequate for testing now.
|
||||
@@ -682,7 +690,7 @@ def test_stdin_closed(self):
|
||||
'''
|
||||
Ensure pexpect continues to operate even when stdin is closed
|
||||
'''
|
||||
- class Closed_stdin_proc(multiprocessing.Process):
|
||||
+ class Closed_stdin_proc(mp_context.Process):
|
||||
def run(self):
|
||||
sys.__stdin__.close()
|
||||
cat = pexpect.spawn('cat')
|
||||
@@ -698,7 +706,7 @@ def test_stdin_stdout_closed(self):
|
||||
'''
|
||||
Ensure pexpect continues to operate even when stdin and stdout is closed
|
||||
'''
|
||||
- class Closed_stdin_stdout_proc(multiprocessing.Process):
|
||||
+ class Closed_stdin_stdout_proc(mp_context.Process):
|
||||
def run(self):
|
||||
sys.__stdin__.close()
|
||||
sys.__stdout__.close()
|
||||
diff --git a/tests/test_socket.py b/tests/test_socket.py
|
||||
index b801b00a..6521d368 100644
|
||||
--- a/tests/test_socket.py
|
||||
+++ b/tests/test_socket.py
|
||||
@@ -29,6 +29,14 @@
|
||||
import time
|
||||
import errno
|
||||
|
||||
+# Python 3.14 changed the non-macOS POSIX default to forkserver
|
||||
+# but the code in this module does not work with it
|
||||
+# See https://github.com/python/cpython/issues/125714
|
||||
+if multiprocessing.get_start_method() == 'forkserver':
|
||||
+ mp_context = multiprocessing.get_context(method='fork')
|
||||
+else:
|
||||
+ mp_context = multiprocessing.get_context()
|
||||
+
|
||||
|
||||
class SocketServerError(Exception):
|
||||
pass
|
||||
@@ -83,8 +91,8 @@ def setUp(self):
|
||||
self.prompt3 = b'Press X to exit:'
|
||||
self.enter = b'\r\n'
|
||||
self.exit = b'X\r\n'
|
||||
- self.server_up = multiprocessing.Event()
|
||||
- self.server_process = multiprocessing.Process(target=self.socket_server, args=(self.server_up,))
|
||||
+ self.server_up = mp_context.Event()
|
||||
+ self.server_process = mp_context.Process(target=self.socket_server, args=(self.server_up,))
|
||||
self.server_process.daemon = True
|
||||
self.server_process.start()
|
||||
counter = 0
|
||||
@@ -189,9 +197,9 @@ def test_timeout(self):
|
||||
session.expect(b'Bogus response')
|
||||
|
||||
def test_interrupt(self):
|
||||
- timed_out = multiprocessing.Event()
|
||||
- all_read = multiprocessing.Event()
|
||||
- test_proc = multiprocessing.Process(target=self.socket_fn, args=(timed_out, all_read))
|
||||
+ timed_out = mp_context.Event()
|
||||
+ all_read = mp_context.Event()
|
||||
+ test_proc = mp_context.Process(target=self.socket_fn, args=(timed_out, all_read))
|
||||
test_proc.daemon = True
|
||||
test_proc.start()
|
||||
while not all_read.is_set():
|
||||
@@ -203,9 +211,9 @@ def test_interrupt(self):
|
||||
self.assertEqual(test_proc.exitcode, errno.ETIMEDOUT)
|
||||
|
||||
def test_multiple_interrupts(self):
|
||||
- timed_out = multiprocessing.Event()
|
||||
- all_read = multiprocessing.Event()
|
||||
- test_proc = multiprocessing.Process(target=self.socket_fn, args=(timed_out, all_read))
|
||||
+ timed_out = mp_context.Event()
|
||||
+ all_read = mp_context.Event()
|
||||
+ test_proc = mp_context.Process(target=self.socket_fn, args=(timed_out, all_read))
|
||||
test_proc.daemon = True
|
||||
test_proc.start()
|
||||
while not all_read.is_set():
|
||||
@@ -1,3 +1,13 @@
|
||||
-------------------------------------------------------------------
|
||||
Mon Sep 8 03:28:29 UTC 2025 - Markéta Machová <mmachova@suse.com>
|
||||
|
||||
- Add upstream py314.patch to fix tests with Python 3.14
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Fri Dec 6 07:28:04 UTC 2024 - Guillaume GARDET <guillaume.gardet@opensuse.org>
|
||||
|
||||
- Disable test_performance as it randomly fails
|
||||
|
||||
-------------------------------------------------------------------
|
||||
Tue Dec 12 15:16:28 UTC 2023 - pgajdos@suse.com
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#
|
||||
# spec file for package python-pexpect
|
||||
#
|
||||
# Copyright (c) 2023 SUSE LLC
|
||||
# Copyright (c) 2025 SUSE LLC and contributors
|
||||
#
|
||||
# All modifications and additions to the file contributed by third parties
|
||||
# remain the property of their copyright owners, unless otherwise agreed
|
||||
@@ -24,6 +24,8 @@ Summary: Pure Python Expect-like module
|
||||
License: ISC
|
||||
URL: https://github.com/pexpect/pexpect
|
||||
Source: https://files.pythonhosted.org/packages/source/p/pexpect/pexpect-%{version}.tar.gz
|
||||
# PATCH-FIX-UPSTREAM https://github.com/pexpect/pexpect/pull/808 Tests: Avoid the multiprocessing forkserver method
|
||||
Patch0: py314.patch
|
||||
BuildRequires: %{python_module pip}
|
||||
BuildRequires: %{python_module ptyprocess}
|
||||
BuildRequires: %{python_module pytest}
|
||||
@@ -73,7 +75,8 @@ export INPUTRC=$(readlink -f .inputrc) TRAVIS=true
|
||||
# test_replwrap - seen failed on s390x, [ ValueError: Continuation prompt found - input was incomplete: ]
|
||||
# test_pxssh - seen failed on s390x, [ pexpect.pxssh.ExceptionPxssh: could not synchronize with original prompt ]
|
||||
# test_interact_exit_unicode - seen failed on s390x [ pexpect.exceptions.EOF: End Of File (EOF). Exception style platform. ]
|
||||
%pytest -k "not (test_large_stdout_stream or test_pager_as_cat or test_replwrap or test_pxssh or test_zsh or test_interrupt or test_multiple_interrupts or test_interact_exit_unicode)"
|
||||
# test_performance - random failures seen on aarch64 [ pexpect.exceptions.TIMEOUT: Timeout exceeded. ]
|
||||
%pytest -k "not (test_large_stdout_stream or test_pager_as_cat or test_replwrap or test_pxssh or test_zsh or test_interrupt or test_multiple_interrupts or test_interact_exit_unicode or test_performance)"
|
||||
|
||||
%files %{python_files}
|
||||
%license LICENSE
|
||||
|
||||
Reference in New Issue
Block a user