From 946d8460ba41fd0d221b37e32c6ff17c0639c2ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20W=C3=A1gner?= Date: Sun, 31 Aug 2025 14:35:19 +0200 Subject: [PATCH] Fix "invalid escape sequence" SyntaxWarnings Use raw strings for consistency and readability. --- python/cxxtest/cxxtest_parser.py | 8 ++++---- python/python3/cxxtest/cxxtest_parser.py | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/python/cxxtest/cxxtest_parser.py b/python/cxxtest/cxxtest_parser.py index 86a58f5..28d91a2 100644 --- a/python/cxxtest/cxxtest_parser.py +++ b/python/cxxtest/cxxtest_parser.py @@ -40,7 +40,7 @@ def scanInputFiles(files, _options): abort( 'No tests defined' ) return [options,suites] -lineCont_re = re.compile('(.*)\\\s*$') +lineCont_re = re.compile(r'(.*)\s*$') def scanInputFile(fileName): '''Scan single input file for test suites''' # mode 'rb' is problematic in python3 - byte arrays don't behave the same as @@ -127,11 +127,11 @@ def scanLineForExceptionHandling( line ): if not options.noExceptionHandling: options.haveExceptionHandling = 1 -classdef = '(?:::\s*)?(?:\w+\s*::\s*)*\w+' -baseclassdef = '(?:public|private|protected)\s+%s' % (classdef,) +classdef = r'(?:::\s*)?(?:\w+\s*::\s*)*\w+' +baseclassdef = r'(?:public|private|protected)\s+%s' % (classdef,) general_suite = r"\bclass\s+(%s)\s*:(?:\s*%s\s*,)*\s*public\s+" \ % (classdef, baseclassdef,) -testsuite = '(?:(?:::)?\s*CxxTest\s*::\s*)?TestSuite' +testsuite = r'(?:(?:::)?\s*CxxTest\s*::\s*)?TestSuite' suites_re = { re.compile( general_suite + testsuite ) : None } generatedSuite_re = re.compile( r'\bCXXTEST_SUITE\s*\(\s*(\w*)\s*\)' ) def scanLineForSuiteStart( fileName, lineNo, line ): diff --git a/python/python3/cxxtest/cxxtest_parser.py b/python/python3/cxxtest/cxxtest_parser.py index 2488e90..e0c60cd 100644 --- a/python/python3/cxxtest/cxxtest_parser.py +++ b/python/python3/cxxtest/cxxtest_parser.py @@ -40,7 +40,7 @@ def scanInputFiles(files, _options): abort( 'No tests defined' ) return [options,suites] -lineCont_re = re.compile('(.*)\\\s*$') +lineCont_re = re.compile(r'(.*)\s*$') def scanInputFile(fileName): '''Scan single input file for test suites''' # mode 'rb' is problematic in python3 - byte arrays don't behave the same as @@ -127,11 +127,11 @@ def scanLineForExceptionHandling( line ): if not options.noExceptionHandling: options.haveExceptionHandling = 1 -classdef = '(?:::\s*)?(?:\w+\s*::\s*)*\w+' -baseclassdef = '(?:public|private|protected)\s+%s' % (classdef,) +classdef = r'(?:::\s*)?(?:\w+\s*::\s*)*\w+' +baseclassdef = r'(?:public|private|protected)\s+%s' % (classdef,) general_suite = r"\bclass\s+(%s)\s*:(?:\s*%s\s*,)*\s*public\s+" \ % (classdef, baseclassdef,) -testsuite = '(?:(?:::)?\s*CxxTest\s*::\s*)?TestSuite' +testsuite = r'(?:(?:::)?\s*CxxTest\s*::\s*)?TestSuite' suites_re = { re.compile( general_suite + testsuite ) : None } generatedSuite_re = re.compile( r'\bCXXTEST_SUITE\s*\(\s*(\w*)\s*\)' ) def scanLineForSuiteStart( fileName, lineNo, line ):