Use bytes for sys.stdout.write in PY2. Closes #161.

This commit is contained in:
Anthony Sottile 2014-09-02 16:11:45 -07:00
parent 37d3dc0c82
commit ecf82ed5e0
4 changed files with 53 additions and 1 deletions

View file

@ -1,9 +1,11 @@
from __future__ import unicode_literals
import mock
import pytest
from pre_commit import color
from pre_commit.output import get_hook_message
from pre_commit.output import sys_stdout_write_wrapper
@pytest.mark.parametrize(
@ -77,3 +79,9 @@ def test_make_sure_postfix_is_not_colored():
assert ret == (
'start' + '.' * 6 + 'post ' + color.RED + 'end' + color.NORMAL + '\n'
)
def test_sys_stdout_write_wrapper_writes():
fake_stream = mock.Mock()
sys_stdout_write_wrapper('hello world', fake_stream)
assert fake_stream.write.call_count == 1