summaryrefslogtreecommitdiff
path: root/tests/test_virtualenv.py
diff options
context:
space:
mode:
authorDonald Stufft <donald@stufft.io>2016-01-19 19:55:31 -0500
committerDonald Stufft <donald@stufft.io>2016-01-19 19:55:31 -0500
commit4ac44d2a1508e86d78e06fa158373e723f3b4dcb (patch)
treebdcd6e4b760bf325d4f079a8f4c1612927df4cf4 /tests/test_virtualenv.py
parent134c9a6c67081cda67befd61bae68a999ed00f48 (diff)
parent130399fdd13152d09e5cb133bf72abd95dc7e5b0 (diff)
downloadvirtualenv-14.0.0.tar.gz
Merge branch 'develop'14.0.0
Diffstat (limited to 'tests/test_virtualenv.py')
-rw-r--r--tests/test_virtualenv.py32
1 files changed, 14 insertions, 18 deletions
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index ca274a0..756cde9 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -20,26 +20,24 @@ def test_resolve_interpreter_with_absolute_path(mock_exists):
"""Should return absolute path if given and exists"""
mock_exists.return_value = True
virtualenv.is_executable = Mock(return_value=True)
+ test_abs_path = os.path.abspath("/usr/bin/python53")
- exe = virtualenv.resolve_interpreter("/usr/bin/python42")
+ exe = virtualenv.resolve_interpreter(test_abs_path)
- assert exe == "/usr/bin/python42", "Absolute path should return as is"
- mock_exists.assert_called_with("/usr/bin/python42")
- virtualenv.is_executable.assert_called_with("/usr/bin/python42")
+ assert exe == test_abs_path, "Absolute path should return as is"
+ mock_exists.assert_called_with(test_abs_path)
+ virtualenv.is_executable.assert_called_with(test_abs_path)
@patch('os.path.exists')
def test_resolve_interpreter_with_nonexistent_interpreter(mock_exists):
- """Should exit when with absolute path if not exists"""
+ """Should SystemExit with an nonexistent python interpreter path"""
mock_exists.return_value = False
- try:
- virtualenv.resolve_interpreter("/usr/bin/python42")
- assert False, "Should raise exception"
- except SystemExit:
- pass
+ with pytest.raises(SystemExit):
+ virtualenv.resolve_interpreter("/usr/bin/python53")
- mock_exists.assert_called_with("/usr/bin/python42")
+ mock_exists.assert_called_with("/usr/bin/python53")
@patch('os.path.exists')
@@ -47,15 +45,13 @@ def test_resolve_interpreter_with_invalid_interpreter(mock_exists):
"""Should exit when with absolute path if not exists"""
mock_exists.return_value = True
virtualenv.is_executable = Mock(return_value=False)
+ invalid = os.path.abspath("/usr/bin/pyt_hon53")
- try:
- virtualenv.resolve_interpreter("/usr/bin/python42")
- assert False, "Should raise exception"
- except SystemExit:
- pass
+ with pytest.raises(SystemExit):
+ virtualenv.resolve_interpreter(invalid)
- mock_exists.assert_called_with("/usr/bin/python42")
- virtualenv.is_executable.assert_called_with("/usr/bin/python42")
+ mock_exists.assert_called_with(invalid)
+ virtualenv.is_executable.assert_called_with(invalid)
def test_activate_after_future_statements():