Prepare adaptation of unittests for python 3.11
authorChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 24 Nov 2023 14:46:46 +0000 (15:46 +0100)
committerChristian Herdtweck <christian.herdtweck@intra2net.com>
Fri, 1 Dec 2023 10:28:03 +0000 (11:28 +0100)
Apparently, error tracebacks will have extra lines with pointers to the
position in the line where the error occurred.

test/test_log_helpers.py

index 46ad2cd..5bafade 100644 (file)
@@ -46,7 +46,8 @@ class LogHelperTest(unittest.TestCase):
                     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()
@@ -107,6 +108,7 @@ class LogHelperTest(unittest.TestCase):
             '    impossible_result = 1/0\n' \
             'ZeroDivisionError: division by zero\n' \
             'info| done testing   [regular levelname=INFO]\n'
+        # will have to add a '  TRACEBACK LINE REPLACED\n' above in future python version
         self.check_expected_contents(expected_contents)
 
     def test_get_logger(self):