summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJurko Gospodnetić <jurko.gospodnetic@pke.hr>2017-12-11 12:42:47 +0100
committerBernat Gabor <bgabor8@bloomberg.net>2018-10-25 11:14:35 +0100
commita2d3b89fecac49f285c384a01d261d3c971e45fb (patch)
treea74bfd44cd7757fd2424e5f51f7a9149d4364175
parentb617e85c840fcd9fd1a9eb7b69c73b7e8d69ae75 (diff)
downloadvirtualenv-a2d3b89fecac49f285c384a01d261d3c971e45fb.tar.gz
test resolve_interpreter() with registered python installations
-rw-r--r--tests/test_virtualenv.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index 62142e7..eb69c64 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -15,6 +15,35 @@ def test_version():
assert virtualenv.virtualenv_version, "Should have version"
+@patch('distutils.spawn.find_executable')
+@patch('virtualenv.is_executable', return_value=True)
+@patch('virtualenv.get_installed_pythons')
+@patch('os.path.exists', return_value=True)
+@patch('os.path.abspath')
+def test_resolve_interpreter_with_installed_python(mock_abspath, mock_exists,
+ mock_get_installed_pythons, mock_is_executable, mock_find_executable):
+ test_tag = 'foo'
+ test_path = '/path/to/foo/python.exe'
+ test_abs_path = 'some-abs-path'
+ test_found_path = 'some-found-path'
+ mock_get_installed_pythons.return_value = {
+ test_tag: test_path,
+ test_tag + '2': test_path + '2'}
+ mock_abspath.return_value = test_abs_path
+ mock_find_executable.return_value = test_found_path
+
+ exe = virtualenv.resolve_interpreter('foo')
+
+ assert exe == test_found_path, \
+ "installed python should be accessible by key"
+
+ mock_get_installed_pythons.assert_called_once_with()
+ mock_abspath.assert_called_once_with(test_path)
+ mock_find_executable.assert_called_once_with(test_path)
+ mock_exists.assert_called_once_with(test_found_path)
+ mock_is_executable.assert_called_once_with(test_found_path)
+
+
@patch('virtualenv.is_executable', return_value=True)
@patch('virtualenv.get_installed_pythons', return_value={'foo': 'bar'})
@patch('os.path.exists', return_value=True)