Skip to content

Commit

Permalink
replace assert_regexp_matches with same manually with re
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasw committed Jun 9, 2024
1 parent 439fd71 commit eb47e69
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
8 changes: 6 additions & 2 deletions tools/rosgraph/test/test_roslogging.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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:

Expand Down
11 changes: 8 additions & 3 deletions tools/rosgraph/test/test_roslogging_user_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit eb47e69

Please sign in to comment.