From eb47e694cd60c2d08550d5db9ff4d60e306e1eae Mon Sep 17 00:00:00 2001 From: Lucas Walter Date: Sun, 9 Jun 2024 15:34:31 -0700 Subject: [PATCH] replace assert_regexp_matches with same manually with re --- tools/rosgraph/test/test_roslogging.py | 8 ++++++-- tools/rosgraph/test/test_roslogging_user_logger.py | 11 ++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/tools/rosgraph/test/test_roslogging.py b/tools/rosgraph/test/test_roslogging.py index 5a2cf65912..f05539ecb0 100644 --- a/tools/rosgraph/test/test_roslogging.py +++ b/tools/rosgraph/test/test_roslogging.py @@ -39,7 +39,8 @@ import sys import re -from nose.tools import assert_regexp_matches +# TODO(lucasw) deprecated? Can't find much about this +# from nose.tools import assert_regexp_matches import rosgraph.roslogging @@ -125,7 +126,10 @@ def test_rosconsole__logging_format(): ]) text = f"{loc} {function}\nexpected: {expected_log_out}\nactual: {log_out}\n{log_outs}" # TODO(lucasw) if there is a mismatch the assert isn't very helpful in where it is - assert_regexp_matches(log_out, expected_log_out, text) + # assert_regexp_matches(log_out, expected_log_out, text) + prog = re.compile(expected_log_out) + result = prog.match(log_out) + assert result # True(result, "matched") finally: diff --git a/tools/rosgraph/test/test_roslogging_user_logger.py b/tools/rosgraph/test/test_roslogging_user_logger.py index fcc661791b..9db7f129ee 100644 --- a/tools/rosgraph/test/test_roslogging_user_logger.py +++ b/tools/rosgraph/test/test_roslogging_user_logger.py @@ -44,7 +44,8 @@ from io import StringIO import sys -from nose.tools import assert_regexp_matches +import re +# from nose.tools import assert_regexp_matches import rosgraph.roslogging @@ -126,7 +127,7 @@ def test_roslogging_user_logger(): loginfo(msg) # TODO(lucasw) 1234 magic number - log_expected = ' '.join([ + expected_log_out = ' '.join([ 'I', os.environ['ROS_IP'], msg, @@ -142,7 +143,11 @@ def test_roslogging_user_logger(): r'[0-9]*\.[0-9]*', r'[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2}', ]) - assert_regexp_matches(lout.getvalue().strip(), log_expected) + log_out = lout.getvalue().strip() + prog = re.compile(expected_log_out) + result = prog.match(log_out) + assert result + # assert_regexp_matches(log_out, log_expected) finally: # restoring default ros handler