From 95cca5edb5fb809df67601c443a95513058c70f3b9e6318833d653748281d366 Mon Sep 17 00:00:00 2001 From: Daniel Garcia Date: Thu, 7 Aug 2025 10:13:23 +0000 Subject: [PATCH] - Add upstream patch fix-test_process_initialization.patch gh#pytest-dev/pytest-xprocess#157 to fix tests in slow machines OBS-URL: https://build.opensuse.org/package/show/devel:languages:python:pytest/python-pytest-xprocess?expand=0&rev=17 --- fix-test_process_initialization.patch | 46 +++++++++++++++++++++++++++ python-pytest-xprocess.changes | 6 ++++ python-pytest-xprocess.spec | 5 ++- 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 fix-test_process_initialization.patch diff --git a/fix-test_process_initialization.patch b/fix-test_process_initialization.patch new file mode 100644 index 0000000..176903b --- /dev/null +++ b/fix-test_process_initialization.patch @@ -0,0 +1,46 @@ +From 75d92c89ec86da5cfc99d711a2b80cd097e7c6fa Mon Sep 17 00:00:00 2001 +From: U2FsdGVkX1 +Date: Fri, 22 Nov 2024 14:32:42 +0800 +Subject: [PATCH 1/2] Add retry for request_response_cycle + (https://github.com/pytest-dev/pytest-xprocess/issues/154) + +--- + CHANGELOG.rst | 7 +++++++ + tests/test_process_initialization.py | 18 +++++++++++++----- + 2 files changed, 20 insertions(+), 5 deletions(-) + +Index: pytest-xprocess-1.0.2/tests/test_process_initialization.py +=================================================================== +--- pytest-xprocess-1.0.2.orig/tests/test_process_initialization.py ++++ pytest-xprocess-1.0.2/tests/test_process_initialization.py +@@ -1,5 +1,6 @@ + import socket + import sys ++import time + from pathlib import Path + + import pytest +@@ -12,11 +13,18 @@ server_path = Path(__file__).parent.join + def request_response_cycle(tcp_port, data): + """test started server instance by sending + request and checking response""" +- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: +- sock.connect(("localhost", tcp_port)) +- sock.sendall(bytes(data, "utf-8")) +- received = str(sock.recv(1024), "utf-8") +- return received == data.upper() ++ for attempt in range(4): ++ try: ++ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: ++ sock.connect(("localhost", tcp_port)) ++ sock.sendall(bytes(data, "utf-8")) ++ received = str(sock.recv(1024), "utf-8") ++ return received == data.upper() ++ except OSError as e: ++ if attempt < 3: ++ time.sleep(1) ++ else: ++ raise e + + + @pytest.mark.parametrize("proc_name", ["s1", "s2", "s3"]) diff --git a/python-pytest-xprocess.changes b/python-pytest-xprocess.changes index e3024cc..ae4ca54 100644 --- a/python-pytest-xprocess.changes +++ b/python-pytest-xprocess.changes @@ -1,3 +1,9 @@ +------------------------------------------------------------------- +Thu Aug 7 10:03:28 UTC 2025 - Daniel Garcia + +- Add upstream patch fix-test_process_initialization.patch + gh#pytest-dev/pytest-xprocess#157 to fix tests in slow machines + ------------------------------------------------------------------- Wed May 7 07:01:03 UTC 2025 - Steve Kowalik diff --git a/python-pytest-xprocess.spec b/python-pytest-xprocess.spec index 762c725..8b47683 100644 --- a/python-pytest-xprocess.spec +++ b/python-pytest-xprocess.spec @@ -24,6 +24,9 @@ Summary: A pytest plugin for managing processes across test runs License: MIT URL: https://github.com/pytest-dev/pytest-xprocess Source: https://files.pythonhosted.org/packages/source/p/pytest-xprocess/pytest-xprocess-%{version}.tar.gz +# PATCH-FIX-UPSTREAM fix-test_process_initialization.patch gh#pytest-dev/pytest-xprocess#157 +# This patch fixes tests in slow machines +Patch0: fix-test_process_initialization.patch BuildRequires: %{python_module pip} BuildRequires: %{python_module psutil} BuildRequires: %{python_module pytest >= 2.8} @@ -43,7 +46,7 @@ during testing. You can also use it to start and pre-configure test-specific databases (i.e. Postgres, Couchdb). %prep -%setup -q -n pytest-xprocess-%{version} +%autosetup -p1 -n pytest-xprocess-%{version} rm -rvf tests/__pycache__ chmod -x README.rst