def check_output_and_error(*args, **kwargs):
 kwargs['stderr'] = STDOUT
 try:
  return check_output(*args, **kwargs)
 except CalledProcessError as e:
  raise CalledProcessErrorWithOutput(returncode=e.returncode, cmd=e.cmd, output=e.output)

def check_output_and_error ( * args , ** kwargs ) : kwargs [ 'stderr' ] = STDOUT try : return check_output ( * args , ** kwargs ) except CalledProcessError as e : raise CalledProcessErrorWithOutput ( returncode = e . returncode , cmd = e . cmd , output = e . output )
like check_output but captures the stderr and raises an exception that incudes all the stdout and stderr output when coerced to str .