From f9a8547ec4dc48da95f77cb03f66e25787125815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20K=C5=82oczko?= Date: Fri, 24 Nov 2023 15:44:53 +0000 Subject: [PATCH] do not hardcode python executable name and use sys.executable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Python executabe name should not be hardcoded. Use instead sys.executable(). Signed-off-by: Tomasz Kłoczko --- tests/test_process_tests.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tests/test_process_tests.py b/tests/test_process_tests.py index 59200d7..5e75b09 100644 --- a/tests/test_process_tests.py +++ b/tests/test_process_tests.py @@ -1,5 +1,6 @@ import os import re +import sys import socket import pytest @@ -13,7 +14,7 @@ def test_wait_for_strings(): - with TestProcess('python', '-c', 'print("foobar")') as proc: + with TestProcess(sys.executable, '-c', 'print("foobar")') as proc: wait_for_strings(proc.read, TIMEOUT, 'foobar') with pytest.raises(AssertionError): with dump_on_error(proc.read): @@ -22,7 +23,7 @@ def test_wait_for_strings(): def test_filebuffer(tmp_path): with tmp_path.joinpath('stdout').open('wb') as fh: - with TestProcess('python', '-c', 'print("foobar")', stdout=fh) as proc: + with TestProcess(sys.executable, '-c', 'print("foobar")', stdout=fh) as proc: wait_for_strings(proc.read, TIMEOUT, 'foobar') with pytest.raises(AssertionError): with dump_on_error(proc.read): @@ -30,7 +31,7 @@ def test_filebuffer(tmp_path): def test_socket(): - with TestProcess('python', '-mhttp.server', '0') as proc: + with TestProcess(sys.executable, '-mhttp.server', '0') as proc: with dump_on_error(proc.read, 'SERVER'): wait_for_strings(proc.read, TIMEOUT, 'Serving HTTP on') (port,) = re.match(r'Serving HTTP on .*? port (\d+) ', proc.read()).groups()