Skip to content

do not hardcode python executable name and use sys.executable - #5

Merged
ionelmc merged 1 commit into
ionelmc:masterfrom
kloczek:master
Dec 17, 2023
Merged

do not hardcode python executable name and use sys.executable#5
ionelmc merged 1 commit into
ionelmc:masterfrom
kloczek:master

Conversation

@kloczek

Copy link
Copy Markdown
Contributor

Python executabe name should not be hardcoded.
Use instead sys.executable().

Without that fix pytest is failing in my build env where I have only python3.

+ /usr/bin/pytest -ra -m 'not network' --exit-0-if-no-units============================= test session starts ==============================platform linux -- Python 3.8.18, pytest-7.4.3, pluggy-1.3.0rootdir: /home/tkloczko/rpmbuild/BUILD/python-process-tests-3.0.0configfile: pytest.initestpaths: testscollected 3 itemstests/test_process_tests.py FFF [100%]=================================== FAILURES ===================================____________________________ test_wait_for_strings _____________________________tests/test_process_tests.py:16: in test_wait_for_strings with TestProcess('python', '-c', 'print("foobar")') as proc:../../BUILDROOT/python-process-tests-3.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/process_tests.py:129: in __init__ self.proc = subprocess.Popen(args, stdout=stdout, **kwargs)/usr/lib64/python3.8/subprocess.py:858: in __init__ self._execute_child(args, executable, preexec_fn, close_fds,/usr/lib64/python3.8/subprocess.py:1720: in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)E FileNotFoundError: [Errno 2] No such file or directory: 'python'_______________________________ test_filebuffer ________________________________tests/test_process_tests.py:25: in test_filebuffer with TestProcess('python', '-c', 'print("foobar")', stdout=fh) as proc:../../BUILDROOT/python-process-tests-3.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/process_tests.py:133: in __init__ self.proc = subprocess.Popen(args, stdout=stdout, **kwargs)/usr/lib64/python3.8/subprocess.py:858: in __init__ self._execute_child(args, executable, preexec_fn, close_fds,/usr/lib64/python3.8/subprocess.py:1720: in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)E FileNotFoundError: [Errno 2] No such file or directory: 'python'_________________________________ test_socket __________________________________tests/test_process_tests.py:33: in test_socket with TestProcess('python', '-mhttp.server', '0') as proc:../../BUILDROOT/python-process-tests-3.0.0-2.fc35.x86_64/usr/lib/python3.8/site-packages/process_tests.py:129: in __init__ self.proc = subprocess.Popen(args, stdout=stdout, **kwargs)/usr/lib64/python3.8/subprocess.py:858: in __init__ self._execute_child(args, executable, preexec_fn, close_fds,/usr/lib64/python3.8/subprocess.py:1720: in _execute_child raise child_exception_type(errno_num, err_msg, err_filename)E FileNotFoundError: [Errno 2] No such file or directory: 'python'=========================== short test summary info ============================FAILED tests/test_process_tests.py::test_wait_for_strings - FileNotFoundError...FAILED tests/test_process_tests.py::test_filebuffer - FileNotFoundError: [Err...FAILED tests/test_process_tests.py::test_socket - FileNotFoundError: [Errno 2...============================== 3 failed in 0.19s ===============================

Python executabe name should not be hardcoded.
Use instead sys.executable().
Signed-off-by: Tomasz Kłoczko <kloczek@github.com>
@ionelmc
ionelmc merged commit 7142aee into ionelmc:masterDec 17, 2023
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@kloczek@ionelmc