From fa9db4ec23b6cf546846ded458d26f10eef40903 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Fri, 5 Sep 2014 14:08:10 -0700 Subject: [PATCH] Fix terminal width detection. --- .pre-commit-config.yaml | 2 +- pre_commit/output.py | 3 +-- tests/commands/install_uninstall_test.py | 5 ++++- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3145d8e7..cedb161f 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,7 +4,7 @@ - id: trailing-whitespace - id: end-of-file-fixer - id: autopep8-wrapper - args: ['-i', '--ignore=E265,E309,E501', '-v'] + args: ['-i', '--ignore=E265,E309,E501'] - id: check-json - id: check-yaml - id: debug-statements diff --git a/pre_commit/output.py b/pre_commit/output.py index dcf4c5cc..cb8427c4 100644 --- a/pre_commit/output.py +++ b/pre_commit/output.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -import os import subprocess import sys @@ -11,7 +10,7 @@ from pre_commit import five # TODO: smell: import side-effects COLS = int( subprocess.Popen( - ['tput', 'cols'], stdout=subprocess.PIPE, stderr=open(os.devnull, 'w'), + ['tput', 'cols'], stdout=subprocess.PIPE, ).communicate()[0] or # Default in the case of no terminal 80 diff --git a/tests/commands/install_uninstall_test.py b/tests/commands/install_uninstall_test.py index c9c89c53..68ee29de 100644 --- a/tests/commands/install_uninstall_test.py +++ b/tests/commands/install_uninstall_test.py @@ -382,7 +382,10 @@ def test_installed_from_venv(tmpdir_factory): # Should still pick up the python from when we installed ret, output = _get_commit_output( tmpdir_factory, - env_base={'HOME': os.environ['HOME']}, + env_base={ + 'HOME': os.environ['HOME'], + 'TERM': os.environ.get('TERM', ''), + }, ) assert ret == 0 assert NORMAL_PRE_COMMIT_RUN.match(output)