@@ -15,44 +15,45 @@ def test_version():
15
15
assert virtualenv .virtualenv_version , "Should have version"
16
16
17
17
18
- @patch ('os.path.exists' )
19
- def test_resolve_interpreter_with_absolute_path (mock_exists ):
18
+ @patch ('virtualenv.is_executable' , return_value = True )
19
+ @patch ('virtualenv.get_installed_pythons' , return_value = {'foo' : 'bar' })
20
+ @patch ('os.path.exists' , return_value = True )
21
+ def test_resolve_interpreter_with_absolute_path (
22
+ mock_exists , mock_get_installed_pythons , mock_is_executable ):
20
23
"""Should return absolute path if given and exists"""
21
- mock_exists .return_value = True
22
- virtualenv .is_executable = Mock (return_value = True )
23
24
test_abs_path = os .path .abspath ("/usr/bin/python53" )
24
25
25
26
exe = virtualenv .resolve_interpreter (test_abs_path )
26
27
27
28
assert exe == test_abs_path , "Absolute path should return as is"
28
29
29
30
mock_exists .assert_called_with (test_abs_path )
30
- virtualenv . is_executable .assert_called_with (test_abs_path )
31
+ mock_is_executable .assert_called_with (test_abs_path )
31
32
32
33
33
- @patch ('os.path.exists' )
34
- def test_resolve_interpreter_with_nonexistent_interpreter (mock_exists ):
34
+ @patch ('virtualenv.get_installed_pythons' , return_value = {'foo' : 'bar' })
35
+ @patch ('os.path.exists' , return_value = False )
36
+ def test_resolve_interpreter_with_nonexistent_interpreter (
37
+ mock_exists , mock_get_installed_pythons ):
35
38
"""Should SystemExit with an nonexistent python interpreter path"""
36
- mock_exists .return_value = False
37
-
38
39
with pytest .raises (SystemExit ):
39
40
virtualenv .resolve_interpreter ("/usr/bin/python53" )
40
41
41
42
mock_exists .assert_called_with ("/usr/bin/python53" )
42
43
43
44
44
- @patch ('os.path.exists' )
45
- def test_resolve_interpreter_with_invalid_interpreter (mock_exists ):
45
+ @patch ('virtualenv.is_executable' , return_value = False )
46
+ @patch ('os.path.exists' , return_value = True )
47
+ def test_resolve_interpreter_with_invalid_interpreter (mock_exists ,
48
+ mock_is_executable ):
46
49
"""Should exit when with absolute path if not exists"""
47
- mock_exists .return_value = True
48
- virtualenv .is_executable = Mock (return_value = False )
49
50
invalid = os .path .abspath ("/usr/bin/pyt_hon53" )
50
51
51
52
with pytest .raises (SystemExit ):
52
53
virtualenv .resolve_interpreter (invalid )
53
54
54
55
mock_exists .assert_called_with (invalid )
55
- virtualenv . is_executable .assert_called_with (invalid )
56
+ mock_is_executable .assert_called_with (invalid )
56
57
57
58
58
59
def test_activate_after_future_statements ():
0 commit comments