def test_get_name_default(self, mock_input): mock_input.return_value = '' i = Virtualenv() name = i.get_name() self.assertEqual(name, 'foo')
def test_get_name(self, mock_input): mock_input.return_value = 'bar' i = Virtualenv() name = i.get_name() self.assertEqual(name, 'bar')
def test_get_path(self, mock_get_name, mock_input): mock_get_name.return_value = 'baz' mock_input.return_value = '/foo/bar' i = Virtualenv() path = i.get_path() self.assertEqual(path, '/foo/bar/baz')
def test_get_path_default(self, mock_get_name, mock_input): mock_get_name.return_value = 'baz' mock_input.return_value = '' user_dir = os.path.expanduser('~') i = Virtualenv() path = i.get_path() self.assertEqual(path, os.path.join(user_dir, '.virtualenvs', 'baz'))
def test_create_import_error(self, mock_sh_import): mock_sh_import.side_effect = ImportError i = Virtualenv() path = i.create() warn = self.mocked_facio_hooks_python_virtualenv_Virtualenv_warning self.assertEqual(path, None) warn.assert_called_with("Please install virtualenv to use the " "python virtualenv hooks")
def test_create(self, mock_get_path, mock_input, mock_virtualenv): mock_get_path.return_value = '/foo/bar/baz' mock_input.return_value = '' i = Virtualenv() path = i.create() mock_virtualenv.assert_called_with('/foo/bar/baz', '--no-site-packages') self.assertEqual(path, '/foo/bar/baz')
def test_create_venv_exception(self, mock_get_path, mock_input, mock_virtualenv): mock_get_path.return_value = '/foo/bar/baz' mock_virtualenv.side_effect = Exception i = Virtualenv() path = i.create() err = self.mocked_facio_hooks_python_virtualenv_Virtualenv_error self.assertEqual(path, None) err.assert_called_with("Failed to create virtual " "environment at: /foo/bar/baz")