mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-24 17:59:23 -06:00
removed meta from stdout; replaced = with : ; handled sys.version newlines; stylized errorlog to md
This commit is contained in:
@@ -104,30 +104,30 @@ def test_log_and_exit(cap_out, mock_store_dir):
|
||||
|
||||
printed = cap_out.get()
|
||||
log_file = os.path.join(mock_store_dir, 'pre-commit.log')
|
||||
printed_lines = printed.splitlines()
|
||||
print(printed_lines)
|
||||
assert len(printed_lines) == 7
|
||||
assert printed_lines[0] == '### version information'
|
||||
assert re.match(r'^pre-commit.version=\d+\.\d+\.\d+$', printed_lines[1])
|
||||
assert printed_lines[2].startswith('sys.version=')
|
||||
assert printed_lines[3].startswith('sys.executable=')
|
||||
assert printed_lines[4] == '### error information'
|
||||
assert printed_lines[5] == 'msg: FatalError: hai'
|
||||
assert printed_lines[6] == 'Check the log at {}'.format(log_file)
|
||||
assert printed == (
|
||||
'msg: FatalError: hai\n' 'Check the log at {}\n'.format(log_file)
|
||||
)
|
||||
|
||||
assert os.path.exists(log_file)
|
||||
with io.open(log_file) as f:
|
||||
logged_lines = f.read().splitlines()
|
||||
assert len(logged_lines) == 7
|
||||
assert printed_lines[0] == '### version information'
|
||||
assert re.match(
|
||||
r'^pre-commit.version=\d+\.\d+\.\d+$',
|
||||
printed_lines[1],
|
||||
logged = f.read()
|
||||
expected = (
|
||||
r'^### version information\n'
|
||||
r'```\n'
|
||||
r'pre-commit.version: \d+\.\d+\.\d+\n'
|
||||
r'sys.version: (.*\n)*'
|
||||
r'sys.executable: .*\n'
|
||||
r'os.name: .*\n'
|
||||
r'sys.platform: .*\n'
|
||||
r'```\n'
|
||||
r'### error information\n'
|
||||
r'```\n'
|
||||
r'msg: FatalError: hai\n'
|
||||
r"I'm a stacktrace\n"
|
||||
r'\n'
|
||||
r'```\n'
|
||||
)
|
||||
assert logged_lines[2].startswith('sys.version=')
|
||||
assert logged_lines[3].startswith('sys.executable=')
|
||||
assert logged_lines[5] == 'msg: FatalError: hai'
|
||||
assert logged_lines[6] == "I'm a stacktrace"
|
||||
assert re.match(expected, logged)
|
||||
|
||||
|
||||
def test_error_handler_non_ascii_exception(mock_store_dir):
|
||||
@@ -139,7 +139,8 @@ def test_error_handler_non_ascii_exception(mock_store_dir):
|
||||
def test_error_handler_no_tty(tempdir_factory):
|
||||
pre_commit_home = tempdir_factory.get()
|
||||
output = cmd_output_mocked_pre_commit_home(
|
||||
sys.executable, '-c',
|
||||
sys.executable,
|
||||
'-c',
|
||||
'from __future__ import unicode_literals\n'
|
||||
'from pre_commit.error_handler import error_handler\n'
|
||||
'with error_handler():\n'
|
||||
|
||||
Reference in New Issue
Block a user