There was an error while loading. Please reload this page.
1 parent 3555a2b commit f88e007Copy full SHA for f88e007
4 files changed
testing/resources/not_installable_repo/.pre-commit-hooks.yaml
testing/resources/not_installable_repo/setup.py
tests/commands/run_test.py
@@ -479,31 +479,6 @@ def test_stdout_write_bug_py26(
479
assert 'UnicodeDecodeError' not in stdout
480
481
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
507
def test_lots_of_files(mock_out_store_directory, tempdir_factory):
508
# windows xargs seems to have a bug, here's a regression test for
509
# our workaround
tests/languages/helpers_test.py
@@ -1,7 +1,13 @@
1
from __future__ import absolute_import
2
from __future__ import unicode_literals
3
4
+import sys
5
+
6
+import pytest
7
8
from pre_commit.languages import helpers
9
+from pre_commit.prefix import Prefix
10
+from pre_commit.util import CalledProcessError
11
12
13
def test_basic_get_default_version():
@@ -10,3 +16,15 @@ def test_basic_get_default_version():
16
17
def test_basic_healthy():
18
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