def test_find_bash_while_not_installed(self, sys_exit, sys_stderr): from subprocess import CalledProcessError exception = CalledProcessError(1, ['which', 'bash']) with mock.patch('subprocess.check_output', side_effect=exception): build.get_bash_path() sys_exit.assert_called_with(1) sys_stderr.write.assert_called_with( 'Bash not found, please install bash')
def test_find_bash(self): with mock.patch('subprocess.check_output', return_value='/bin/bash\n') as check_output: bash = build.get_bash_path() self.assertEqual('/bin/bash', bash) check_output.assert_called_with( ['which', 'bash'])