Skip to content

Commit a2d3b89

Browse files
jurko-gospodneticgaborbernat
authored andcommitted
test resolve_interpreter() with registered python installations
1 parent b617e85 commit a2d3b89

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

tests/test_virtualenv.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,35 @@ def test_version():
1515
assert virtualenv.virtualenv_version, "Should have version"
1616

1717

18+
@patch('distutils.spawn.find_executable')
19+
@patch('virtualenv.is_executable', return_value=True)
20+
@patch('virtualenv.get_installed_pythons')
21+
@patch('os.path.exists', return_value=True)
22+
@patch('os.path.abspath')
23+
def test_resolve_interpreter_with_installed_python(mock_abspath, mock_exists,
24+
mock_get_installed_pythons, mock_is_executable, mock_find_executable):
25+
test_tag = 'foo'
26+
test_path = '/path/to/foo/python.exe'
27+
test_abs_path = 'some-abs-path'
28+
test_found_path = 'some-found-path'
29+
mock_get_installed_pythons.return_value = {
30+
test_tag: test_path,
31+
test_tag + '2': test_path + '2'}
32+
mock_abspath.return_value = test_abs_path
33+
mock_find_executable.return_value = test_found_path
34+
35+
exe = virtualenv.resolve_interpreter('foo')
36+
37+
assert exe == test_found_path, \
38+
"installed python should be accessible by key"
39+
40+
mock_get_installed_pythons.assert_called_once_with()
41+
mock_abspath.assert_called_once_with(test_path)
42+
mock_find_executable.assert_called_once_with(test_path)
43+
mock_exists.assert_called_once_with(test_found_path)
44+
mock_is_executable.assert_called_once_with(test_found_path)
45+
46+
1847
@patch('virtualenv.is_executable', return_value=True)
1948
@patch('virtualenv.get_installed_pythons', return_value={'foo': 'bar'})
2049
@patch('os.path.exists', return_value=True)

0 commit comments

Comments
 (0)