From df4acd3978b40df1be89ed144b0f18e2c9d615c5 Mon Sep 17 00:00:00 2001 From: Pedro Algarvio Date: Thu, 31 Oct 2019 12:23:12 +0000 Subject: [PATCH] Try to use the same version matching python binary --- tests/integration/modules/test_pip.py | 17 ++++++++++++++++- tests/integration/states/test_pip_state.py | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/tests/integration/modules/test_pip.py b/tests/integration/modules/test_pip.py index 77962b7982..c98d8b923c 100644 --- a/tests/integration/modules/test_pip.py +++ b/tests/integration/modules/test_pip.py @@ -68,7 +68,22 @@ class PipModuleTest(ModuleCase): if salt.utils.is_windows(): python = os.path.join(sys.real_prefix, os.path.basename(sys.executable)) else: - python = os.path.join(sys.real_prefix, 'bin', os.path.basename(sys.executable)) + python_binary_names = [ + 'python{}.{}'.format(*sys.version_info), + 'python{}'.format(*sys.version_info), + 'python' + ] + for binary_name in python_binary_names: + python = os.path.join(sys.real_prefix, 'bin', binary_name) + if os.path.exists(python): + break + else: + self.fail( + 'Couldn\'t find a python binary name under \'{}\' matching: {}'.format( + os.path.join(sys.real_prefix, 'bin'), + python_binary_names + ) + ) # We're running off a virtualenv, and we don't want to create a virtualenv off of # a virtualenv kwargs = {'python': python} diff --git a/tests/integration/states/test_pip_state.py b/tests/integration/states/test_pip_state.py index e80e67e7bc..b10949410a 100644 --- a/tests/integration/states/test_pip_state.py +++ b/tests/integration/states/test_pip_state.py @@ -87,7 +87,22 @@ class PipStateTest(ModuleCase, SaltReturnAssertsMixin): if salt.utils.is_windows(): python = os.path.join(sys.real_prefix, os.path.basename(sys.executable)) else: - python = os.path.join(sys.real_prefix, 'bin', os.path.basename(sys.executable)) + python_binary_names = [ + 'python{}.{}'.format(*sys.version_info), + 'python{}'.format(*sys.version_info), + 'python' + ] + for binary_name in python_binary_names: + python = os.path.join(sys.real_prefix, 'bin', binary_name) + if os.path.exists(python): + break + else: + self.fail( + 'Couldn\'t find a python binary name under \'{}\' matching: {}'.format( + os.path.join(sys.real_prefix, 'bin'), + python_binary_names + ) + ) # We're running off a virtualenv, and we don't want to create a virtualenv off of # a virtualenv, let's point to the actual python that created the virtualenv kwargs = {'python': python}