def test_run_non_zero_exit_code( self, mock_pwd, mock_popen, mock_get_path_to_python, mock_input, mock_chdir, mock_log_errors): mock_pwd.return_value = '/bar' mock_get_path_to_python.return_value = '/foo/python' mock_input.return_value = 'develop' mock_attrs = { 'communicate.return_value': ('', ''), 'returncode': 1 } mock_popen.return_value = MagicMock(**mock_attrs) i = Setup() r = i.run() self.assertFalse(r) mock_popen.assert_any_call( ['/foo/python', '/bar/foo/setup.py', 'develop'], stderr=-1, stdout=-1)
def test_get_python_path_input(self, mock_input): mock_input.return_value = '/foo/bar/python' i = Setup() path = i.get_path_to_python() self.assertEqual(path, '/foo/bar/python')
def test_get_install_arg(self, mock_input): mock_input.return_value = 'develop' i = Setup() arg = i.get_install_arg() self.assertEqual(arg, 'develop')
def test_get_default_path_virtualenv(self): self.mock_state.hook_calls = [('facio.hooks.python.virtualenv', '/foo/bar')] i = Setup() path = i.get_default_path_to_python() self.assertEqual('/foo/bar/bin/python', path)
def test_get_default_path_virtualenv(self): self.mock_state.hook_calls = [( 'facio.hooks.python.virtualenv', '/foo/bar' )] i = Setup() path = i.get_default_path_to_python() self.assertEqual('/foo/bar/bin/python', path)
def test_get_install_arg_input_error(self, mock_input): mock_input.return_value = 'foo' i = Setup() arg = i.get_install_arg() e = self.mocked_facio_hooks_python_setup_Setup_error self.assertEqual(arg, None) e.assert_called_with("You did not enter a valid setup.py arg")
def test_log_errors(self): patcher = patch('facio.hooks.python.setup.open', mock_open(), create=True) m = patcher.start() i = Setup() i.log_errors("I am an error") handler = m.return_value.__enter__.return_value handler.write.assert_called_with("I am an error") patcher.stop()
def test_run_non_zero_exit_code(self, mock_pwd, mock_popen, mock_get_path_to_python, mock_input, mock_chdir, mock_log_errors): mock_pwd.return_value = '/bar' mock_get_path_to_python.return_value = '/foo/python' mock_input.return_value = 'develop' mock_attrs = {'communicate.return_value': ('', ''), 'returncode': 1} mock_popen.return_value = MagicMock(**mock_attrs) i = Setup() r = i.run() self.assertFalse(r) mock_popen.assert_any_call( ['/foo/python', '/bar/foo/setup.py', 'develop'], stderr=-1, stdout=-1)
def test_get_default_python_path_current(self): i = Setup() path = i.get_default_path_to_python() self.assertEqual(sys.executable, path)