diff --git a/0001-Modify-the-setup.py-file.patch b/0001-Modify-the-setup.py-file.patch index b40f44e3c234c905839b686dd90deb8f079f57e1..408533f83ef8a9a74e44227a59dcdaad6ab320df 100644 --- a/0001-Modify-the-setup.py-file.patch +++ b/0001-Modify-the-setup.py-file.patch @@ -4,21 +4,21 @@ Date: Fri, 10 Feb 2023 09:21:20 +0800 Subject: [PATCH] Modify the setup.py file --- - setup.py | 1 + - 1 file changed, 1 insertion(+) + setup.py | 1 + + 1 files changed, 1 insertions(+) diff --git a/setup.py b/setup.py -index 5e4b8f9..95e33c4 100755 +index 7a92b4a..46580ab 100755 --- a/setup.py +++ b/setup.py @@ -3,6 +3,7 @@ from setuptools import setup if __name__ == "__main__": setup( name="pytest-xprocess", -+ version="0.22.2", ++ version="1.0.2", # this is for GitHub's dependency graph - install_requires=["pytest>=2.8", "psutil", "py"], + install_requires=["pytest>=2.8", "psutil"], ) -- -2.33.0 +2.43.0 diff --git a/0002-remove-support-for-callback.patch b/0002-remove-support-for-callback.patch new file mode 100644 index 0000000000000000000000000000000000000000..d9c4c79828d1290a6bac247e31a19a58faf7a91a --- /dev/null +++ b/0002-remove-support-for-callback.patch @@ -0,0 +1,214 @@ +From d8f714c005a13cc3b1a00f6b65c53f63ca0e03c4 Mon Sep 17 00:00:00 2001 +From: wang__ge +Date: Thu, 29 Aug 2024 11:36:14 +0800 +Subject: [PATCH] remove support for callback + +--- + tests/test_process_initialization.py | 106 +++++++++++++-------------- + xprocess/xprocess.py | 56 +++++++------- + 2 files changed, 83 insertions(+), 79 deletions(-) + +diff --git a/tests/test_process_initialization.py b/tests/test_process_initialization.py +index 03a7c49..8567f97 100644 +--- a/tests/test_process_initialization.py ++++ b/tests/test_process_initialization.py +@@ -118,56 +118,56 @@ def test_popen_kwargs(tcp_port, proc_name, xprocess): + info.terminate() + + +-@pytest.mark.parametrize("proc_name", ["s1", "s2", "s3"]) +-def test_startup_without_pattern(tcp_port, proc_name, xprocess): +- data = "bacon\n" +- +- class Starter(ProcessStarter): +- args = [sys.executable, server_path, tcp_port, "--no-children"] +- +- def startup_check(self): +- return request_response_cycle(tcp_port, data) +- +- xprocess.ensure(proc_name, Starter) +- info = xprocess.getinfo(proc_name) +- assert info.isrunning() +- info.terminate() +- +- +-@pytest.mark.parametrize( +- "proc_name,proc_pttrn,lines", +- [ +- ("s1", "will not match", 21), +- ("s2", "spam, bacon, eggs", 30), +- ("s3", "finally started", 130), +- ], +-) +-def test_startup_with_pattern_and_callback( +- tcp_port, proc_name, proc_pttrn, lines, xprocess +-): +- data = "bacon\n" +- +- class Starter(ProcessStarter): +- pattern = proc_pttrn +- max_read_lines = lines +- args = [sys.executable, server_path, tcp_port, "--no-children"] +- +- def startup_check(self): +- return request_response_cycle(tcp_port, data) +- +- if proc_name == "s1": +- with pytest.raises(RuntimeError): +- xprocess.ensure(proc_name, Starter) +- # since we made xprocess fail to start the server on purpose, we cannot +- # terminate it using XProcessInfo.terminate method once it does not +- # know the PID, process name or even that it is running, so we tell the +- # server to terminate itself. +- with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: +- sock.connect(("localhost", tcp_port)) +- sock.sendall(bytes("exit\n", "utf-8")) +- else: +- xprocess.ensure(proc_name, Starter) +- info = xprocess.getinfo(proc_name) +- assert info.isrunning() +- assert request_response_cycle(tcp_port, data) +- info.terminate() ++#@pytest.mark.parametrize("proc_name", ["s1", "s2", "s3"]) ++#def test_startup_without_pattern(tcp_port, proc_name, xprocess): ++# data = "bacon\n" ++ ++# class Starter(ProcessStarter): ++# args = [sys.executable, server_path, tcp_port, "--no-children"] ++ ++# def startup_check(self): ++# return request_response_cycle(tcp_port, data) ++ ++# xprocess.ensure(proc_name, Starter) ++# info = xprocess.getinfo(proc_name) ++# assert info.isrunning() ++# info.terminate() ++ ++ ++#@pytest.mark.parametrize( ++# "proc_name,proc_pttrn,lines", ++# [ ++# ("s1", "will not match", 21), ++# ("s2", "spam, bacon, eggs", 30), ++# ("s3", "finally started", 130), ++# ], ++#) ++#def test_startup_with_pattern_and_callback( ++# tcp_port, proc_name, proc_pttrn, lines, xprocess ++#): ++# data = "bacon\n" ++ ++# class Starter(ProcessStarter): ++# pattern = proc_pttrn ++# max_read_lines = lines ++# args = [sys.executable, server_path, tcp_port, "--no-children"] ++ ++# def startup_check(self): ++# return request_response_cycle(tcp_port, data) ++ ++# if proc_name == "s1": ++# with pytest.raises(RuntimeError): ++# xprocess.ensure(proc_name, Starter) ++# # since we made xprocess fail to start the server on purpose, we cannot ++# # terminate it using XProcessInfo.terminate method once it does not ++# # know the PID, process name or even that it is running, so we tell the ++# # server to terminate itself. ++# with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock: ++# sock.connect(("localhost", tcp_port)) ++# sock.sendall(bytes("exit\n", "utf-8")) ++# else: ++# xprocess.ensure(proc_name, Starter) ++# info = xprocess.getinfo(proc_name) ++# assert info.isrunning() ++# assert request_response_cycle(tcp_port, data) ++# info.terminate() +diff --git a/xprocess/xprocess.py b/xprocess/xprocess.py +index 0df85f4..98388bc 100644 +--- a/xprocess/xprocess.py ++++ b/xprocess/xprocess.py +@@ -360,7 +360,7 @@ class ProcessStarter(ABC): + terminate_on_interrupt = False + + def __init__(self, control_dir, process): +- self._max_time = None ++ #self._max_time = None + self.control_dir = control_dir + self.process = process + +@@ -368,12 +368,13 @@ class ProcessStarter(ABC): + @abstractmethod + def args(self): + """The args to start the process.""" +- pass ++ #pass + + @property ++ @abstractmethod + def pattern(self): + """The pattern to match when the process has started.""" +- return None ++ #return None + + def startup_check(self): + """Used to assert process responsiveness after pattern match""" +@@ -398,31 +399,34 @@ class ProcessStarter(ABC): + + def wait(self, log_file): + """Wait until the pattern is matched or callback returns successful.""" +- has_callback = type(self).startup_check != ProcessStarter.startup_check +- has_pattern = self.pattern is not None +- # cut it short, at least one provided way to +- # know if the process has started +- if not has_callback and not has_pattern: +- return False +- # here we know that at least one of them has been provided +- pattern_ok, callback_ok = False, False ++ #has_callback = type(self).startup_check != ProcessStarter.startup_check ++ #has_pattern = self.pattern is not None ++ ## cut it short, at least one provided way to ++ ## know if the process has started ++ #if not has_callback and not has_pattern: ++ # return False ++ ## here we know that at least one of them has been provided ++ #pattern_ok, callback_ok = False, False + self._max_time = datetime.now() + timedelta(seconds=self.timeout) +- if has_pattern: +- pattern_ok = self.wait_pattern(log_file) +- if has_callback: +- callback_ok = self.wait_callback() +- # when both provided, both should be checked +- if has_callback and has_pattern: +- return pattern_ok and callback_ok +- # one or the other +- return pattern_ok or callback_ok +- +- def wait_pattern(self, log_file): +- """Wait until the pattern is mached and callback returns successful.""" +- raw_lines = self.get_lines(log_file) +- lines = map(self.log_line, self.filter_lines(raw_lines)) ++ lines = map(self.log_line, self.filter_lines(self.get_lines(log_file))) ++ #if has_pattern: ++ # pattern_ok = self.wait_pattern(log_file) ++ #if has_callback: ++ # callback_ok = self.wait_callback() ++ ## when both provided, both should be checked ++ #if has_callback and has_pattern: ++ # return pattern_ok and callback_ok ++ ## one or the other ++ #return pattern_ok or callback_ok ++ ++ #def wait_pattern(self, log_file): ++ #"""Wait until the pattern is mached and callback returns successful.""" ++ #raw_lines = self.get_lines(log_file) ++ #lines = map(self.log_line, self.filter_lines(raw_lines)) + has_match = any(re.search(self.pattern, line) for line in lines) +- return has_match ++ process_ready = self.wait_callback() ++ return has_match and process_ready ++ #return has_match + + def filter_lines(self, lines): + """fetch first , ignoring blank lines.""" +-- +2.43.0 + diff --git a/pytest-xprocess-0.23.0.tar.gz b/pytest-xprocess-0.23.0.tar.gz deleted file mode 100644 index c9927fab22891a20fd90f7cf968e7bb9927ed0b7..0000000000000000000000000000000000000000 Binary files a/pytest-xprocess-0.23.0.tar.gz and /dev/null differ diff --git a/pytest-xprocess-1.0.2.tar.gz b/pytest-xprocess-1.0.2.tar.gz new file mode 100644 index 0000000000000000000000000000000000000000..eecaf9f28feee3b8069fde74f653b7f96622d59e Binary files /dev/null and b/pytest-xprocess-1.0.2.tar.gz differ diff --git a/python-pytest-xprocess.spec b/python-pytest-xprocess.spec index b1ad32032712cec0d65be6a25f5ad12ea88c1c01..1a1f00f7f5a82111360e84fc1a8a070746e4eea5 100644 --- a/python-pytest-xprocess.spec +++ b/python-pytest-xprocess.spec @@ -1,13 +1,14 @@ %global _empty_manifest_terminate_build 0 Name: python-pytest-xprocess -Version: 0.23.0 +Version: 1.0.2 Release: 1 Summary: Pytest plugin to manage external processes across test runs License: MIT URL: https://github.com/pytest-dev/pytest-xprocess/ -Source0: https://files.pythonhosted.org/packages/b7/68/90298f409cf7f939d183233421114ea3535be3fd5be3a8e4070863175374/pytest-xprocess-0.23.0.tar.gz +Source0: %{pypi_source pytest-xprocess} BuildArch: noarch - +Patch1: 0001-Modify-the-setup.py-file.patch +Patch2: 0002-remove-support-for-callback.patch Requires: python3-pytest Requires: python3-psutil @@ -71,6 +72,9 @@ mv %{buildroot}/doclist.lst . %{_docdir}/* %changelog +* Thu Aug 29 2024 Ge Wang - 1.0.2-1 +- Update package to version 1.0.2 + * Tue Mar 12 2024 jiangxinyu - 0.23.0-1 - Update package to version 0.23.0