Skip to content

Commit 8a5e98e

Browse files
committed
testMonitorForbidsMasks: Allow ERR_ERRONEUSNICKNAME reply
This is returned by Sable
1 parent 61ae4bc commit 8a5e98e

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

irctest/cases.py

+9
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ def messageEqual(self, msg: Message, **kwargs: Any) -> bool:
160160
def messageDiffers(
161161
self,
162162
msg: Message,
163+
command: Union[str, None, patma.Operator] = None,
163164
params: Optional[List[Union[str, None, patma.Operator]]] = None,
164165
target: Optional[str] = None,
165166
tags: Optional[
@@ -186,6 +187,14 @@ def messageDiffers(
186187
msg=msg,
187188
)
188189

190+
if command is not None and not patma.match_string(msg.command, command):
191+
fail_msg = (
192+
fail_msg or "expected command to match {expects}, got {got}: {msg}"
193+
)
194+
return fail_msg.format(
195+
*extra_format, got=msg.command, expects=command, msg=msg
196+
)
197+
189198
if prefix is not None and not patma.match_string(msg.prefix, prefix):
190199
fail_msg = (
191200
fail_msg or "expected prefix to match {expects}, got {got}: {msg}"

irctest/server_tests/monitor.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from irctest import cases, runner
99
from irctest.client_mock import NoMessageException
1010
from irctest.numerics import (
11+
ERR_ERRONEUSNICKNAME,
1112
RPL_ENDOFMONLIST,
1213
RPL_MONLIST,
1314
RPL_MONOFFLINE,
@@ -190,14 +191,15 @@ def testMonitorForbidsMasks(self):
190191
self.check_server_support()
191192
self.sendLine(1, "MONITOR + *!username@localhost")
192193
self.sendLine(1, "MONITOR + *[email protected]")
194+
expected_command = StrRe(f"({RPL_MONOFFLINE}|{ERR_ERRONEUSNICKNAME})")
193195
try:
194196
m = self.getMessage(1)
195-
self.assertMessageMatch(m, command="731")
197+
self.assertMessageMatch(m, command=expected_command)
196198
except NoMessageException:
197199
pass
198200
else:
199201
m = self.getMessage(1)
200-
self.assertMessageMatch(m, command="731")
202+
self.assertMessageMatch(m, command=expected_command)
201203
self.connectClient("bar")
202204
try:
203205
m = self.getMessage(1)

0 commit comments

Comments
 (0)