Skip to content

Commit

Permalink
matched
Browse files Browse the repository at this point in the history
  • Loading branch information
marcin-usielski committed Aug 7, 2024
1 parent ab44e47 commit 71078cb
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
3 changes: 2 additions & 1 deletion moler/device/textualdevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,8 @@ def _prompts_observer_callback(self, event):
occurrence = event.get_last_occurrence()
state = occurrence["state"]
line = occurrence["line"]
msg = f"Callback for state {state} for line >>{line}<<"
matched = occurrence["matched"]
msg = f"Callback for state {state} for line >>{line}<<, matched: '{matched}'."
if self.current_state != state:
self._log(level=logging.INFO, msg=msg)
self._set_state(state)
Expand Down
1 change: 1 addition & 0 deletions moler/events/unix/wait4prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def _parse_prompts(self, line):
current_ret = {
"line": line,
"prompt_regex": prompt_regex.pattern,
"matched": self._regex_helper.group(0),
"state": self.compiled_prompts_regex[prompt_regex],
"time": datetime.datetime.now(),
}
Expand Down
4 changes: 4 additions & 0 deletions test/events/unix/test_event_wait4prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@ def _prompts_observer_callback(event):
occurrence = event.get_last_occurrence()
state = occurrence["state"]
line = occurrence["line"]
matched = occurrence["matched"]
nonlocal was_callback_called
was_callback_called = True
try:
assert state == "UNIX_LOCAL"
assert line == "moler_bash#"
assert matched == "moler_bash#"
except AssertionError as err:
nonlocal error
error = err
Expand Down Expand Up @@ -67,11 +69,13 @@ def _prompts_observer_callback(event):
occurrence = event.get_last_occurrence()
state = occurrence["state"]
line = occurrence["line"]
matched = occurrence["matched"]
nonlocal was_callback_called
was_callback_called =True
try:
assert state == "UNIX_LOCAL"
assert line == "moler_bash#"
assert matched == "moler_bash#"
except AssertionError as err:
nonlocal error
error = err
Expand Down

0 comments on commit 71078cb

Please sign in to comment.