def test_CalledProcessError_str_nooutput(): error = CalledProcessError(1, ('exe', ), 0, b'', b'') assert str(error) == ("command: ('exe',)\n" 'return code: 1\n' 'expected return code: 0\n' 'stdout: (none)\n' 'stderr: (none)')
def test_CalledProcessError_str(): error = CalledProcessError(1, [str('git'), str('status')], 0, (str('stdout'), str('stderr'))) assert str(error) == ("Command: ['git', 'status']\n" "Return code: 1\n" "Expected return code: 0\n" "Output: ('stdout', 'stderr')\n")
def test_CalledProcessError_str(): error = CalledProcessError(1, ('exe', ), 0, b'output', b'errors') assert str(error) == ("command: ('exe',)\n" 'return code: 1\n' 'expected return code: 0\n' 'stdout:\n' ' output\n' 'stderr:\n' ' errors')
def test_CalledProcessError_str_nooutput(): error = CalledProcessError(1, [five.n('git'), five.n('status')], 0, (five.n(''), five.n(''))) assert str(error) == ("Command: ['git', 'status']\n" "Return code: 1\n" "Expected return code: 0\n" "Output: (none)\n" "Errors: (none)\n")
def test_CalledProcessError_str_nooutput(): error = CalledProcessError( 1, [str('git'), str('status')], 0, (str(''), str('')), ) assert str(error) == ("Command: ['git', 'status']\n" 'Return code: 1\n' 'Expected return code: 0\n' 'Output: (none)\n' 'Errors: (none)\n')
def test_CalledProcessError_str(): error = CalledProcessError( 1, [five.n('git'), five.n('status')], 0, (five.n('stdout'), five.n('stderr')), ) assert str(error) == ("Command: ['git', 'status']\n" "Return code: 1\n" "Expected return code: 0\n" "Output: \n" " stdout\n" "Errors: \n" " stderr\n")
def fake_shallow_clone(self, *args, **kwargs): raise CalledProcessError(None, None, None)
def test_docker_is_running_process_error(): with mock.patch( 'pre_commit.languages.docker.cmd_output_b', side_effect=CalledProcessError(*(None, ) * 4), ): assert docker.docker_is_running() is False
def test_error_handler_non_utf8_exception(mock_store_dir): with pytest.raises(SystemExit): with error_handler.error_handler(): raise CalledProcessError(1, ('exe',), 0, b'error: \xa0\xe1', b'')
def test_get_docker_path_in_docker_docker_in_docker(in_docker): # won't be able to discover "self" container in true docker-in-docker err = CalledProcessError(1, (), 0, b'', b'') with mock.patch.object(docker, 'cmd_output_b', side_effect=err): assert docker._get_docker_path('/project') == '/project'