Skip to content

Commit f88e007

Browse files
committed
Fix test since pip 10 changed output
1 parent 3555a2b commit f88e007

File tree

4 files changed

+18
-48
lines changed

4 files changed

+18
-48
lines changed

testing/resources/not_installable_repo/.pre-commit-hooks.yaml

Lines changed: 0 additions & 6 deletions
This file was deleted.

testing/resources/not_installable_repo/setup.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

tests/commands/run_test.py

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -479,31 +479,6 @@ def test_stdout_write_bug_py26(
479479
assert 'UnicodeDecodeError' not in stdout
480480

481481

482-
def test_hook_install_failure(mock_out_store_directory, tempdir_factory):
483-
git_path = make_consuming_repo(tempdir_factory, 'not_installable_repo')
484-
with cwd(git_path):
485-
install(Runner(git_path, C.CONFIG_FILE))
486-
487-
_, stdout, _ = cmd_output_mocked_pre_commit_home(
488-
'git', 'commit', '-m', 'Commit!',
489-
# git commit puts pre-commit to stderr
490-
stderr=subprocess.STDOUT,
491-
retcode=None,
492-
encoding=None,
493-
tempdir_factory=tempdir_factory,
494-
)
495-
assert b'UnicodeDecodeError' not in stdout
496-
# Doesn't actually happen, but a reasonable assertion
497-
assert b'UnicodeEncodeError' not in stdout
498-
499-
# Sanity check our output
500-
assert (
501-
b'An unexpected error has occurred: CalledProcessError: ' in
502-
stdout
503-
)
504-
assert '☃'.encode('UTF-8') + '²'.encode('latin1') in stdout
505-
506-
507482
def test_lots_of_files(mock_out_store_directory, tempdir_factory):
508483
# windows xargs seems to have a bug, here's a regression test for
509484
# our workaround

tests/languages/helpers_test.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
from __future__ import absolute_import
22
from __future__ import unicode_literals
33

4+
import sys
5+
6+
import pytest
7+
48
from pre_commit.languages import helpers
9+
from pre_commit.prefix import Prefix
10+
from pre_commit.util import CalledProcessError
511

612

713
def test_basic_get_default_version():
@@ -10,3 +16,15 @@ def test_basic_get_default_version():
1016

1117
def test_basic_healthy():
1218
assert helpers.basic_healthy(None, None) is True
19+
20+
21+
def test_failed_setup_command_does_not_unicode_error():
22+
script = (
23+
'import sys\n'
24+
"getattr(sys.stderr, 'buffer', sys.stderr).write(b'\\x81\\xfe')\n"
25+
'exit(1)\n'
26+
)
27+
28+
# an assertion that this does not raise `UnicodeError`
29+
with pytest.raises(CalledProcessError):
30+
helpers.run_setup_cmd(Prefix('.'), (sys.executable, '-c', script))

0 commit comments

Comments
 (0)