import os
from os.path import isfile, basename
import re
+import sys
from src import log_helpers
enumerate(zip(log_reader, expected_contents.splitlines())):
if re.match(r'\d{1,2}:\d{2}:\d{2}:\d{3}\s+', actual_line):
cmp_line = actual_line[13:].rstrip()
- elif re.match(r'\s*File ".+", line \d+, in .+', actual_line):
+ elif re.match(r'\s*File ".+", line \d+, in .+', actual_line) \
+ or re.match(r'\s+~\^~\s*', actual_line):
cmp_line = ' TRACEBACK LINE REPLACED'
else:
cmp_line = actual_line.rstrip()
- self.assertEqual(cmp_line, expect_line)
+ self.assertEqual(cmp_line, expect_line,
+ msg="Unexpected line in output (line {line_no+1}:\n" \
+ "expect: {expect_line}\n" \
+ " got: {cmp_line}")
def test_short_level_format(self):
"""Tests that calls to :py:class:`ShortLevelFormatter` do not fail."""
'err | 1/0 still does not work! [regular levelname=ERROR]\n' \
'Traceback (most recent call last):\n' \
' TRACEBACK LINE REPLACED\n' \
- ' impossible_result = 1/0\n' \
+ ' impossible_result = 1/0\n'
+ if sys.version_info[0] > 3 or sys.version_info[0] == 3 and sys.version_info[1] > 7:
+ expected_contents += ' TRACEBACK LINE REPLACED\n'
+ expected_contents += \
'ZeroDivisionError: division by zero\n' \
'info| done testing [regular levelname=INFO]\n'
self.check_expected_contents(expected_contents)