def test_raises_no_such_file(self):
		try:
			utils.run_shell('bamboowang')
		except OSError as e:
			eq_(e.errno, errno.ENOENT)
		else:
			ok_(False, 'Should have raised OSError')
	def test_raises_no_such_file_with_check_for_interrupt(self):
		try:
			utils.run_shell('bamboowang', check_for_interrupt=True)
		except OSError as e:
			eq_(e.errno, errno.ENOENT)
		else:
			ok_(False, 'Should have raised OSError')
	def test_raises_on_error_check(self):
		try:
			fail_script = path.abspath(path.join(__file__, '..', 'fixtures', 'fail.sh'))
			utils.run_shell('sh', fail_script, check_for_interrupt=True)
		except utils.ShellError as e:
			expected = 'I failed because I am fail.\n'
			message = (
				'Exception should have had attached output: %s, but had %s' % (expected, e.output)
			)
			eq_(e.output, expected, message)
		else:
			ok_(False, 'Should have raised ShellError')
	def test_should_pass_in_required_preexec(self, required_preexec, Popen):
		Popen.side_effect = self._fake_popen
		utils.run_shell('foo', create_process_group=True)

		Popen.assert_called_once()
		assert_call_got_kwargs(Popen, 0, preexec_fn=required_preexec.return_value)
	def test_preexec_fn_is_none_by_default(self, Popen):
		Popen.side_effect = self._fake_popen
		utils.run_shell('foo')

		Popen.assert_called_once()
		assert_call_got_kwargs(Popen, 0, preexec_fn=None)
	def test_no_shell_output_with_check(self):
		eq_(utils.run_shell('echo', '-n', check_for_interrupt=True), '')
	def test_no_shell_output(self):
		eq_(utils.run_shell('echo', '-n'), '')
	def test_returns_output_with_check(self):
		eq_(utils.run_shell('echo', 'hello world', check_for_interrupt=True), 'hello world\n')
	def test_returns_output(self):
		eq_(utils.run_shell('echo', 'hello world'), 'hello world\n')