mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 00:04:42 +04:00
Change cmd_output_bs retcode arg to a boolean check
This commit is contained in:
parent
71925c47ea
commit
84b38f7b89
15 changed files with 28 additions and 26 deletions
|
|
@ -135,7 +135,7 @@ def test_init_templatedir_skip_on_missing_config(
|
|||
retcode, output = git_commit(
|
||||
fn=cmd_output_mocked_pre_commit_home,
|
||||
tempdir_factory=tempdir_factory,
|
||||
retcode=None,
|
||||
check=False,
|
||||
)
|
||||
|
||||
assert retcode == commit_retcode
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ def _get_commit_output(tempdir_factory, touch_file='foo', **kwargs):
|
|||
cmd_output('git', 'add', touch_file)
|
||||
return git_commit(
|
||||
fn=cmd_output_mocked_pre_commit_home,
|
||||
retcode=None,
|
||||
check=False,
|
||||
tempdir_factory=tempdir_factory,
|
||||
**kwargs,
|
||||
)
|
||||
|
|
@ -286,7 +286,7 @@ def test_environment_not_sourced(tempdir_factory, store):
|
|||
'GIT_AUTHOR_EMAIL': os.environ['GIT_AUTHOR_EMAIL'],
|
||||
'GIT_COMMITTER_EMAIL': os.environ['GIT_COMMITTER_EMAIL'],
|
||||
},
|
||||
retcode=None,
|
||||
check=False,
|
||||
)
|
||||
assert ret == 1
|
||||
assert out == (
|
||||
|
|
@ -551,7 +551,7 @@ def _get_push_output(tempdir_factory, remote='origin', opts=()):
|
|||
return cmd_output_mocked_pre_commit_home(
|
||||
'git', 'push', remote, 'HEAD:new_branch', *opts,
|
||||
tempdir_factory=tempdir_factory,
|
||||
retcode=None,
|
||||
check=False,
|
||||
)[:2]
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -718,7 +718,7 @@ def test_non_ascii_hook_id(repo_with_passing_hook, tempdir_factory):
|
|||
with cwd(repo_with_passing_hook):
|
||||
_, stdout, _ = cmd_output_mocked_pre_commit_home(
|
||||
sys.executable, '-m', 'pre_commit.main', 'run', '☃',
|
||||
retcode=None, tempdir_factory=tempdir_factory,
|
||||
check=False, tempdir_factory=tempdir_factory,
|
||||
)
|
||||
assert 'UnicodeDecodeError' not in stdout
|
||||
# Doesn't actually happen, but a reasonable assertion
|
||||
|
|
@ -737,7 +737,7 @@ def test_stdout_write_bug_py26(repo_with_failing_hook, store, tempdir_factory):
|
|||
_, out = git_commit(
|
||||
fn=cmd_output_mocked_pre_commit_home,
|
||||
tempdir_factory=tempdir_factory,
|
||||
retcode=None,
|
||||
check=False,
|
||||
)
|
||||
assert 'UnicodeEncodeError' not in out
|
||||
# Doesn't actually happen, but a reasonable assertion
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ def _make_conflict():
|
|||
bar_only_file.write('bar')
|
||||
cmd_output('git', 'add', 'bar_only_file')
|
||||
git_commit(msg=_make_conflict.__name__)
|
||||
cmd_output('git', 'merge', 'foo', retcode=None)
|
||||
cmd_output('git', 'merge', 'foo', check=False)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
|
|
|
|||
|
|
@ -183,10 +183,11 @@ def test_error_handler_no_tty(tempdir_factory):
|
|||
'from pre_commit.error_handler import error_handler\n'
|
||||
'with error_handler():\n'
|
||||
' raise ValueError("\\u2603")\n',
|
||||
retcode=3,
|
||||
check=False,
|
||||
tempdir_factory=tempdir_factory,
|
||||
pre_commit_home=pre_commit_home,
|
||||
)
|
||||
assert ret == 3
|
||||
log_file = os.path.join(pre_commit_home, 'pre-commit.log')
|
||||
out_lines = out.splitlines()
|
||||
assert out_lines[-2] == 'An unexpected error has occurred: ValueError: ☃'
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ def test_is_in_merge_conflict_submodule(in_conflicting_submodule):
|
|||
def test_cherry_pick_conflict(in_merge_conflict):
|
||||
cmd_output('git', 'merge', '--abort')
|
||||
foo_ref = cmd_output('git', 'rev-parse', 'foo')[1].strip()
|
||||
cmd_output('git', 'cherry-pick', foo_ref, retcode=None)
|
||||
cmd_output('git', 'cherry-pick', foo_ref, check=False)
|
||||
assert git.is_in_merge_conflict() is False
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -83,14 +83,14 @@ def test_tmpdir():
|
|||
|
||||
|
||||
def test_cmd_output_exe_not_found():
|
||||
ret, out, _ = cmd_output('dne', retcode=None)
|
||||
ret, out, _ = cmd_output('dne', check=False)
|
||||
assert ret == 1
|
||||
assert out == 'Executable `dne` not found'
|
||||
|
||||
|
||||
@pytest.mark.parametrize('fn', (cmd_output_b, cmd_output_p))
|
||||
def test_cmd_output_exe_not_found_bytes(fn):
|
||||
ret, out, _ = fn('dne', retcode=None, stderr=subprocess.STDOUT)
|
||||
ret, out, _ = fn('dne', check=False, stderr=subprocess.STDOUT)
|
||||
assert ret == 1
|
||||
assert out == b'Executable `dne` not found'
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ def test_cmd_output_no_shebang(tmpdir, fn):
|
|||
make_executable(f)
|
||||
|
||||
# previously this raised `OSError` -- the output is platform specific
|
||||
ret, out, _ = fn(str(f), retcode=None, stderr=subprocess.STDOUT)
|
||||
ret, out, _ = fn(str(f), check=False, stderr=subprocess.STDOUT)
|
||||
assert ret == 1
|
||||
assert isinstance(out, bytes)
|
||||
assert out.endswith(b'\n')
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue