mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Fix test since pip 10 changed output
This commit is contained in:
parent
3555a2b158
commit
f88e007f52
4 changed files with 18 additions and 48 deletions
|
|
@ -1,6 +0,0 @@
|
||||||
- id: foo
|
|
||||||
name: Foo
|
|
||||||
entry: foo
|
|
||||||
language: python
|
|
||||||
language_version: python2.7
|
|
||||||
files: \.py$
|
|
||||||
|
|
@ -1,17 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
from __future__ import print_function
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
import sys
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
|
||||||
# Intentionally write mixed encoding to the output. This should not crash
|
|
||||||
# pre-commit and should write bytes to the output.
|
|
||||||
sys.stderr.write('☃'.encode('UTF-8') + '²'.encode('latin1') + b'\n')
|
|
||||||
# Return 1 to indicate failures
|
|
||||||
return 1
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
|
||||||
exit(main())
|
|
||||||
|
|
@ -479,31 +479,6 @@ def test_stdout_write_bug_py26(
|
||||||
assert 'UnicodeDecodeError' not in stdout
|
assert 'UnicodeDecodeError' not in stdout
|
||||||
|
|
||||||
|
|
||||||
def test_hook_install_failure(mock_out_store_directory, tempdir_factory):
|
|
||||||
git_path = make_consuming_repo(tempdir_factory, 'not_installable_repo')
|
|
||||||
with cwd(git_path):
|
|
||||||
install(Runner(git_path, C.CONFIG_FILE))
|
|
||||||
|
|
||||||
_, stdout, _ = cmd_output_mocked_pre_commit_home(
|
|
||||||
'git', 'commit', '-m', 'Commit!',
|
|
||||||
# git commit puts pre-commit to stderr
|
|
||||||
stderr=subprocess.STDOUT,
|
|
||||||
retcode=None,
|
|
||||||
encoding=None,
|
|
||||||
tempdir_factory=tempdir_factory,
|
|
||||||
)
|
|
||||||
assert b'UnicodeDecodeError' not in stdout
|
|
||||||
# Doesn't actually happen, but a reasonable assertion
|
|
||||||
assert b'UnicodeEncodeError' not in stdout
|
|
||||||
|
|
||||||
# Sanity check our output
|
|
||||||
assert (
|
|
||||||
b'An unexpected error has occurred: CalledProcessError: ' in
|
|
||||||
stdout
|
|
||||||
)
|
|
||||||
assert '☃'.encode('UTF-8') + '²'.encode('latin1') in stdout
|
|
||||||
|
|
||||||
|
|
||||||
def test_lots_of_files(mock_out_store_directory, tempdir_factory):
|
def test_lots_of_files(mock_out_store_directory, tempdir_factory):
|
||||||
# windows xargs seems to have a bug, here's a regression test for
|
# windows xargs seems to have a bug, here's a regression test for
|
||||||
# our workaround
|
# our workaround
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
|
||||||
from pre_commit.languages import helpers
|
from pre_commit.languages import helpers
|
||||||
|
from pre_commit.prefix import Prefix
|
||||||
|
from pre_commit.util import CalledProcessError
|
||||||
|
|
||||||
|
|
||||||
def test_basic_get_default_version():
|
def test_basic_get_default_version():
|
||||||
|
|
@ -10,3 +16,15 @@ def test_basic_get_default_version():
|
||||||
|
|
||||||
def test_basic_healthy():
|
def test_basic_healthy():
|
||||||
assert helpers.basic_healthy(None, None) is True
|
assert helpers.basic_healthy(None, None) is True
|
||||||
|
|
||||||
|
|
||||||
|
def test_failed_setup_command_does_not_unicode_error():
|
||||||
|
script = (
|
||||||
|
'import sys\n'
|
||||||
|
"getattr(sys.stderr, 'buffer', sys.stderr).write(b'\\x81\\xfe')\n"
|
||||||
|
'exit(1)\n'
|
||||||
|
)
|
||||||
|
|
||||||
|
# an assertion that this does not raise `UnicodeError`
|
||||||
|
with pytest.raises(CalledProcessError):
|
||||||
|
helpers.run_setup_cmd(Prefix('.'), (sys.executable, '-c', script))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue