@@ -104,30 +104,30 @@ def test_log_and_exit(cap_out, mock_store_dir):
104104
105105 printed = cap_out .get ()
106106 log_file = os .path .join (mock_store_dir , 'pre-commit.log' )
107- printed_lines = printed .splitlines ()
108- print (printed_lines )
109- assert len (printed_lines ) == 7
110- assert printed_lines [0 ] == '### version information'
111- assert re .match (r'^pre-commit.version=\d+\.\d+\.\d+$' , printed_lines [1 ])
112- assert printed_lines [2 ].startswith ('sys.version=' )
113- assert printed_lines [3 ].startswith ('sys.executable=' )
114- assert printed_lines [4 ] == '### error information'
115- assert printed_lines [5 ] == 'msg: FatalError: hai'
116- assert printed_lines [6 ] == 'Check the log at {}' .format (log_file )
107+ assert printed == (
108+ 'msg: FatalError: hai\n ' 'Check the log at {}\n ' .format (log_file )
109+ )
117110
118111 assert os .path .exists (log_file )
119112 with io .open (log_file ) as f :
120- logged_lines = f .read ().splitlines ()
121- assert len (logged_lines ) == 7
122- assert printed_lines [0 ] == '### version information'
123- assert re .match (
124- r'^pre-commit.version=\d+\.\d+\.\d+$' ,
125- printed_lines [1 ],
113+ logged = f .read ()
114+ expected = (
115+ r'^### version information\n'
116+ r'```\n'
117+ r'pre-commit.version: \d+\.\d+\.\d+\n'
118+ r'sys.version: (.*\n)*'
119+ r'sys.executable: .*\n'
120+ r'os.name: .*\n'
121+ r'sys.platform: .*\n'
122+ r'```\n'
123+ r'### error information\n'
124+ r'```\n'
125+ r'msg: FatalError: hai\n'
126+ r"I'm a stacktrace\n"
127+ r'\n'
128+ r'```\n'
126129 )
127- assert logged_lines [2 ].startswith ('sys.version=' )
128- assert logged_lines [3 ].startswith ('sys.executable=' )
129- assert logged_lines [5 ] == 'msg: FatalError: hai'
130- assert logged_lines [6 ] == "I'm a stacktrace"
130+ assert re .match (expected , logged )
131131
132132
133133def test_error_handler_non_ascii_exception (mock_store_dir ):
@@ -139,7 +139,8 @@ def test_error_handler_non_ascii_exception(mock_store_dir):
139139def test_error_handler_no_tty (tempdir_factory ):
140140 pre_commit_home = tempdir_factory .get ()
141141 output = cmd_output_mocked_pre_commit_home (
142- sys .executable , '-c' ,
142+ sys .executable ,
143+ '-c' ,
143144 'from __future__ import unicode_literals\n '
144145 'from pre_commit.error_handler import error_handler\n '
145146 'with error_handler():\n '
0 commit comments