From 2bccde4db80d6a9643fc9d9ff28fb369e90c7df6 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 8 Feb 2026 00:11:34 -0500 Subject: [PATCH 1/2] clean up most OptionalExtensionNotSupported --- irctest/controllers/ergo.py | 6 ++- irctest/controllers/inspircd.py | 8 +++- irctest/runner.py | 9 ++++ irctest/server_tests/chathistory.py | 7 +++- irctest/server_tests/chmodes/ban.py | 9 ++-- .../server_tests/chmodes/invite_exception.py | 9 ++-- irctest/server_tests/join.py | 9 ++-- irctest/server_tests/labeled_responses.py | 6 +-- irctest/server_tests/message_tags.py | 4 +- irctest/server_tests/metadata_2.py | 5 ++- irctest/server_tests/names.py | 5 ++- irctest/server_tests/sasl.py | 10 ++--- irctest/server_tests/who.py | 17 ++++---- irctest/server_tests/whowas.py | 3 +- irctest/specifications.py | 41 +++++++++++++++++++ 15 files changed, 111 insertions(+), 37 deletions(-) diff --git a/irctest/controllers/ergo.py b/irctest/controllers/ergo.py index 8743d5d8..68694cf1 100644 --- a/irctest/controllers/ergo.py +++ b/irctest/controllers/ergo.py @@ -181,10 +181,14 @@ class ErgoController(BaseServerController, DirectoryBasedController): optional_behaviors = frozenset( ( + OptionalBehaviors.BAN_EXCEPTION_MODE, OptionalBehaviors.CAP_REQ_MINUS, + OptionalBehaviors.INVITE_EXCEPTION_MODE, + OptionalBehaviors.MULTI_JOIN, + OptionalBehaviors.MULTI_PRIVMSG, OptionalBehaviors.NO_CTCP, OptionalBehaviors.SASL_AFTER_REGISTRATION, - OptionalBehaviors.SASL_REAUTHENTICATION, + # OptionalBehaviors.SASL_REAUTHENTICATION is NOT supported :-) ) ) diff --git a/irctest/controllers/inspircd.py b/irctest/controllers/inspircd.py index 1195a4f1..55ed9281 100644 --- a/irctest/controllers/inspircd.py +++ b/irctest/controllers/inspircd.py @@ -127,7 +127,13 @@ class InspircdController(BaseServerController, DirectoryBasedController): supports_sts = False extban_mute_char = "m" - optional_behaviors = frozenset([OptionalBehaviors.NO_CTCP]) + optional_behaviors = frozenset( + [ + OptionalBehaviors.BAN_EXCEPTION_MODE, + OptionalBehaviors.INVITE_EXCEPTION_MODE, + OptionalBehaviors.NO_CTCP, + ] + ) def create_config(self) -> None: super().create_config() diff --git a/irctest/runner.py b/irctest/runner.py index 5d9a931b..d3f8fa49 100644 --- a/irctest/runner.py +++ b/irctest/runner.py @@ -1,5 +1,11 @@ +from __future__ import annotations + +from typing import TYPE_CHECKING import unittest +if TYPE_CHECKING: + from irctest.specifications import OptionalBehaviors + class NotImplementedByController(unittest.SkipTest, NotImplementedError): def __str__(self) -> str: @@ -15,6 +21,9 @@ def __str__(self) -> str: class OptionalBehaviorNotSupported(unittest.SkipTest): + def __init__(self, reason: OptionalBehaviors) -> None: + super().__init__(reason.value) + def __str__(self) -> str: return f"Optional behavior not supported: {self.args[0]}" diff --git a/irctest/server_tests/chathistory.py b/irctest/server_tests/chathistory.py index 04d2ef8b..3a7bde3d 100644 --- a/irctest/server_tests/chathistory.py +++ b/irctest/server_tests/chathistory.py @@ -5,10 +5,11 @@ import functools import secrets import time +import unittest import pytest -from irctest import cases, runner +from irctest import cases from irctest.irc_utils.junkdrawer import random_name from irctest.patma import ANYSTR, StrRe @@ -23,7 +24,9 @@ def skip_ngircd(f): @functools.wraps(f) def newf(self, *args, **kwargs): if self.controller.software_name == "ngIRCd": - raise runner.OptionalExtensionNotSupported("nicks longer 9 characters") + raise unittest.SkipTest( + "ngIRCd does not support nicks longer than 9 characters" + ) return f(self, *args, **kwargs) return newf diff --git a/irctest/server_tests/chmodes/ban.py b/irctest/server_tests/chmodes/ban.py index d0f48292..cf470f84 100644 --- a/irctest/server_tests/chmodes/ban.py +++ b/irctest/server_tests/chmodes/ban.py @@ -9,6 +9,7 @@ from irctest import cases, runner from irctest.numerics import ERR_BANNEDFROMCHAN, RPL_BANLIST, RPL_ENDOFBANLIST from irctest.patma import ANYSTR, StrRe +from irctest.specifications import OptionalBehaviors class BanModeTestCase(cases.BaseServerTestCase): @@ -105,8 +106,8 @@ def testBanException(self): mode = "e" if "CHANMODES" in self.server_support: if "e" not in self.server_support["CHANMODES"]: - raise runner.OptionalExtensionNotSupported( - "Ban exception (or mode letter is not +e)" + raise runner.OptionalBehaviorNotSupported( + OptionalBehaviors.BAN_EXCEPTION_MODE, ) self.assertIn( mode, @@ -115,7 +116,9 @@ def testBanException(self): "but 'e' is not in group A", ) else: - raise runner.OptionalExtensionNotSupported("ISUPPORT CHANMODES") + raise runner.OptionalBehaviorNotSupported( + OptionalBehaviors.BAN_EXCEPTION_MODE, + ) self.sendLine("chanop", "JOIN #chan") self.getMessages("chanop") diff --git a/irctest/server_tests/chmodes/invite_exception.py b/irctest/server_tests/chmodes/invite_exception.py index 820d6754..1c2b7e82 100644 --- a/irctest/server_tests/chmodes/invite_exception.py +++ b/irctest/server_tests/chmodes/invite_exception.py @@ -9,6 +9,7 @@ from irctest import cases, runner from irctest.numerics import ERR_INVITEONLYCHAN, RPL_ENDOFINVEXLIST, RPL_INVEXLIST from irctest.patma import ANYSTR, StrRe +from irctest.specifications import OptionalBehaviors @cases.mark_isupport("INVEX") @@ -37,8 +38,8 @@ def getInviteExceptionMode(self) -> str: if self.server_support and "CHANMODES" in self.server_support: chanmodes = self.server_support["CHANMODES"] if chanmodes and "I" not in chanmodes: - raise runner.OptionalExtensionNotSupported( - "Invite exception (or mode letter is not +I)" + raise runner.OptionalBehaviorNotSupported( + OptionalBehaviors.INVITE_EXCEPTION_MODE, ) if chanmodes: self.assertIn( @@ -48,7 +49,9 @@ def getInviteExceptionMode(self) -> str: "but 'I' is not in group A", ) else: - raise runner.OptionalExtensionNotSupported("ISUPPORT CHANMODES") + raise runner.OptionalBehaviorNotSupported( + OptionalBehaviors.INVITE_EXCEPTION_MODE, + ) return mode @cases.mark_specifications("Modern") diff --git a/irctest/server_tests/join.py b/irctest/server_tests/join.py index 9ccdeb3e..71980adc 100644 --- a/irctest/server_tests/join.py +++ b/irctest/server_tests/join.py @@ -14,6 +14,7 @@ RPL_NAMREPLY, ) from irctest.patma import ANYSTR, StrRe +from irctest.specifications import OptionalBehaviors ERR_BADCHANNAME = "479" # Hybrid only, and conflicts with others @@ -113,7 +114,7 @@ def testJoinPartiallyInvalid(self): """TODO: specify this in Modern""" self.connectClient("foo") if int(self.targmax.get("JOIN") or "4") < 2: - raise runner.OptionalExtensionNotSupported("multi-channel JOIN") + raise runner.OptionalBehaviorNotSupported(OptionalBehaviors.MULTI_JOIN) self.sendLine(1, "JOIN #valid,inv@lid") messages = self.getMessages(1) @@ -155,7 +156,7 @@ def testJoinPartiallyInvalidLabeledResponse(self): "foo", capabilities=["batch", "labeled-response"], skip_if_cap_nak=True ) if int(self.targmax.get("JOIN") or "4") < 2: - raise runner.OptionalExtensionNotSupported("multi-channel JOIN") + raise runner.OptionalBehaviorNotSupported(OptionalBehaviors.MULTI_JOIN) self.sendLine(1, "@label=label1 JOIN #valid,inv@lid") messages = self.getMessages(1) @@ -222,7 +223,7 @@ def testJoinKeys(self): """Joins two channels, both with keys""" self.connectClient("chanop") if self.targmax.get("JOIN", "1000") == "1": - raise runner.OptionalExtensionNotSupported("Multi-target JOIN") + raise runner.OptionalBehaviorNotSupported(OptionalBehaviors.MULTI_JOIN) self.joinChannel(1, "#chan1") self.sendLine(1, "MODE #chan1 +k key1") self.getMessages(1) @@ -252,7 +253,7 @@ def testJoinManySingleKey(self): """Joins two channels, the first one has a key.""" self.connectClient("chanop") if self.targmax.get("JOIN", "1000") == "1": - raise runner.OptionalExtensionNotSupported("Multi-target JOIN") + raise runner.OptionalBehaviorNotSupported(OptionalBehaviors.MULTI_JOIN) self.joinChannel(1, "#chan1") self.sendLine(1, "MODE #chan1 +k key1") self.getMessages(1) diff --git a/irctest/server_tests/labeled_responses.py b/irctest/server_tests/labeled_responses.py index b6e8bd98..6704aa5f 100644 --- a/irctest/server_tests/labeled_responses.py +++ b/irctest/server_tests/labeled_responses.py @@ -9,10 +9,10 @@ import pytest -from irctest import cases +from irctest import cases, runner from irctest.numerics import ERR_UNKNOWNCOMMAND from irctest.patma import ANYDICT, ANYOPTSTR, NotStrRe, RemainingKeys, StrRe -from irctest.runner import OptionalExtensionNotSupported +from irctest.specifications import OptionalBehaviors class LabeledResponsesTestCase(cases.BaseServerTestCase): @@ -24,7 +24,7 @@ def testLabeledPrivmsgResponsesToMultipleClients(self): skip_if_cap_nak=True, ) if int(self.targmax.get("PRIVMSG", "1") or "4") < 3: - raise OptionalExtensionNotSupported("PRIVMSG to multiple targets") + raise runner.OptionalBehaviorNotSupported(OptionalBehaviors.MULTI_PRIVMSG) self.getMessages(1) self.connectClient( diff --git a/irctest/server_tests/message_tags.py b/irctest/server_tests/message_tags.py index e626ead7..2282c02b 100644 --- a/irctest/server_tests/message_tags.py +++ b/irctest/server_tests/message_tags.py @@ -213,9 +213,7 @@ def testRecipientCapability(self): if clienttagdeny: parts = clienttagdeny.split(",") if "*" in parts and "+draft/reply" not in parts: - raise runner.OptionalExtensionNotSupported( - "CLIENTTAGDENY blocks +draft/reply" - ) + raise runner.ImplementationChoice("CLIENTTAGDENY blocks +draft/reply") self.connectClient("bob") self.getMessages(1) diff --git a/irctest/server_tests/metadata_2.py b/irctest/server_tests/metadata_2.py index 5712d9aa..8914ed41 100644 --- a/irctest/server_tests/metadata_2.py +++ b/irctest/server_tests/metadata_2.py @@ -11,6 +11,7 @@ from irctest import cases, runner from irctest.numerics import RPL_METADATASUBOK, RPL_WHOISKEYVALUE from irctest.patma import ANYDICT, ANYLIST, ANYSTR, Either +from irctest.specifications import OptionalBehaviors CLIENT_NICKS = { 1: "foo", @@ -563,8 +564,8 @@ def testSetGetValidBeforeConnect(self): self.sendLine(1, "CAP LS 302") caps = self.getCapLs(1) if "before-connect" not in (caps.get("draft/metadata-2") or "").split(","): - raise runner.OptionalExtensionNotSupported( - "draft/metadata-2=before-connect" + raise runner.OptionalBehaviorNotSupported( + OptionalBehaviors.METADATA_BEFORE_CONNECT ) self.requestCapabilities(1, ["draft/metadata-2", "batch"], skip_if_cap_nak=True) diff --git a/irctest/server_tests/names.py b/irctest/server_tests/names.py index 6cff4a30..ba1cc186 100644 --- a/irctest/server_tests/names.py +++ b/irctest/server_tests/names.py @@ -8,6 +8,7 @@ from irctest import cases, runner from irctest.numerics import RPL_ENDOFNAMES, RPL_NAMREPLY from irctest.patma import ANYSTR, StrRe +from irctest.specifications import OptionalBehaviors class NamesTestCase(cases.BaseServerTestCase): @@ -105,7 +106,9 @@ def _testNamesMultipleChannels(self, symbol): self.connectClient("nick1") if self.targmax.get("NAMES", "1") == "1": - raise runner.OptionalExtensionNotSupported("Multi-target NAMES") + raise runner.OptionalBehaviorNotSupported( + OptionalBehaviors.MULTI_NAMES_COMMAND + ) self.sendLine(1, "JOIN #chan1") self.sendLine(1, "JOIN #chan2") diff --git a/irctest/server_tests/sasl.py b/irctest/server_tests/sasl.py index 91abd340..1dfdfaf1 100644 --- a/irctest/server_tests/sasl.py +++ b/irctest/server_tests/sasl.py @@ -459,7 +459,7 @@ def testPlainPostRegistration(self): time.sleep(2) m = self.getMessage(1) if m.command == ERR_ALREADYREGISTERED: - raise runner.OptionalExtensionNotSupported( + raise runner.OptionalBehaviorNotSupported( OptionalBehaviors.SASL_AFTER_REGISTRATION ) self.assertMessageMatch( @@ -496,7 +496,7 @@ def testPlainPostRegistrationAndReAuthenticate(self): time.sleep(2) m = self.getMessage(1) if m.command == ERR_ALREADYREGISTERED: - raise runner.OptionalExtensionNotSupported( + raise runner.OptionalBehaviorNotSupported( OptionalBehaviors.SASL_AFTER_REGISTRATION ) self.assertMessageMatch( @@ -522,7 +522,7 @@ def testPlainPostRegistrationAndReAuthenticate(self): "replied with “AUTHENTICATE +” or 907 (ERR_SASLALREADY), " "but instead sent: {msg}", ) - raise runner.OptionalExtensionNotSupported( + raise runner.OptionalBehaviorNotSupported( OptionalBehaviors.SASL_REAUTHENTICATION ) self.assertMessageMatch( @@ -564,7 +564,7 @@ def testPlainReAuthenticate(self): time.sleep(2) m = self.getMessage(1) if m.command == ERR_ALREADYREGISTERED: - raise runner.OptionalExtensionNotSupported( + raise runner.OptionalBehaviorNotSupported( OptionalBehaviors.SASL_AFTER_REGISTRATION ) elif m.command == ERR_SASLALREADY: @@ -576,7 +576,7 @@ def testPlainReAuthenticate(self): "replied with “AUTHENTICATE +” or 907 (ERR_SASLALREADY), " "but instead sent: {msg}", ) - raise runner.OptionalExtensionNotSupported( + raise runner.OptionalBehaviorNotSupported( OptionalBehaviors.SASL_REAUTHENTICATION ) self.assertMessageMatch( diff --git a/irctest/server_tests/who.py b/irctest/server_tests/who.py index 7a2ce84f..507bc624 100644 --- a/irctest/server_tests/who.py +++ b/irctest/server_tests/who.py @@ -6,6 +6,7 @@ """ import re +import unittest import pytest @@ -88,7 +89,7 @@ class WhoTestCase(BaseWhoTestCase, cases.BaseServerTestCase): @cases.mark_specifications("Modern") def testWhoStar(self): if self.controller.software_name in ("Bahamut",): - raise runner.OptionalExtensionNotSupported("WHO mask") + raise unittest.SkipTest("Bahamut does not support WHO mask") self._init() @@ -119,7 +120,7 @@ def testWhoStar(self): @cases.mark_specifications("Modern") def testWhoNick(self, mask): if "*" in mask and self.controller.software_name in ("Bahamut",): - raise runner.OptionalExtensionNotSupported("WHO mask") + raise unittest.SkipTest("Bahamut does not support WHO mask") self._init() @@ -149,7 +150,7 @@ def testWhoNick(self, mask): ) def testWhoUsernameRealName(self, mask): if "*" in mask and self.controller.software_name in ("Bahamut",): - raise runner.OptionalExtensionNotSupported("WHO mask") + raise unittest.SkipTest("Bahamut does not support WHO mask") self._init() @@ -202,7 +203,7 @@ def testWhoRealNameSpaces(self): @cases.mark_specifications("Modern") def testWhoNickAway(self, mask): if "*" in mask and self.controller.software_name in ("Bahamut",): - raise runner.OptionalExtensionNotSupported("WHO mask") + raise unittest.SkipTest("Bahamut does not support WHO mask") self._init() @@ -236,7 +237,7 @@ def testWhoNickAway(self, mask): @cases.mark_specifications("Modern") def testWhoNickOper(self, mask): if "*" in mask and self.controller.software_name in ("Bahamut",): - raise runner.OptionalExtensionNotSupported("WHO mask") + raise unittest.SkipTest("Bahamut does not support WHO mask") self._init() @@ -275,7 +276,7 @@ def testWhoNickOper(self, mask): @cases.mark_specifications("Modern") def testWhoNickAwayAndOper(self, mask): if "*" in mask and self.controller.software_name in ("Bahamut",): - raise runner.OptionalExtensionNotSupported("WHO mask") + raise unittest.SkipTest("Bahamut does not support WHO mask") self._init() @@ -309,7 +310,7 @@ def testWhoNickAwayAndOper(self, mask): @cases.mark_specifications("Modern") def testWhoChan(self, mask): if "*" in mask and self.controller.software_name in ("Bahamut",): - raise runner.OptionalExtensionNotSupported("WHO mask") + raise unittest.SkipTest("Bahamut does not support WHO mask") self._init() @@ -633,7 +634,7 @@ class WhoInvisibleTestCase(cases.BaseServerTestCase): @cases.mark_specifications("Modern") def testWhoInvisible(self): if self.controller.software_name in ("Bahamut",): - raise runner.OptionalExtensionNotSupported("WHO mask") + raise unittest.SkipTest("Bahamut does not support WHO mask") self.connectClient("evan", name="evan") self.sendLine("evan", "MODE evan +i") diff --git a/irctest/server_tests/whowas.py b/irctest/server_tests/whowas.py index c45f572f..5c0b7815 100644 --- a/irctest/server_tests/whowas.py +++ b/irctest/server_tests/whowas.py @@ -8,6 +8,7 @@ """ import time +import unittest import pytest @@ -275,7 +276,7 @@ def testWhowasWildcard(self): -- https://modern.ircdocs.horse/#whowas-message """ if self.controller.software_name == "Bahamut": - raise runner.OptionalExtensionNotSupported("WHOWAS mask") + raise unittest.SkipTest("Bahamut does not support WHOWAS masks") self._testWhowasMultiple(second_result=True, whowas_command="WHOWAS *ck2") diff --git a/irctest/specifications.py b/irctest/specifications.py index f7b7ae01..19760067 100644 --- a/irctest/specifications.py +++ b/irctest/specifications.py @@ -73,6 +73,13 @@ def from_name(cls, name: str) -> IsupportTokens: @enum.unique class OptionalBehaviors(enum.Enum): + BAN_EXCEPTION_MODE = "+e ban exception list channel mode" + """ + Widely implemented channel mode +I, taking a list of NUH masks + that are allowed to join the channel even if they match a mask + in the +b ban list. + """ + CAP_REQ_MINUS = "`CAP REQ -capname` to disable `capname`" """ Ability to disable capabilities at runtime: @@ -80,6 +87,40 @@ class OptionalBehaviors(enum.Enum): to designate that the capability should be disabled. """ + INVITE_EXCEPTION_MODE = "+I invite exception list channel mode" + """ + Widely implemented channel mode +I, taking a list of NUH masks + that are always considered invited to the channel (bypassing the +i + invite-only mode). + """ + + METADATA_BEFORE_CONNECT = "draft/metadata-2=before-connect" + """ + Optional feature in draft/metadata-2 allowing clients to set metadata + on themselves before completing connection registration. + """ + + MULTI_JOIN = "JOIN multiple channels with one command" + """ + Ability to JOIN multiple channels on a single JOIN line, e.g. + `JOIN #baz,#bat`; see https://modern.ircdocs.horse/#targmax-parameter + for context. + """ + + MULTI_NAMES_COMMAND = "NAMES command supports requesting multiple channels" + """ + Ability to request membership lists for multiple channels on a single + NAMES line, e.g. `NAMES #baz,bat`; see + https://modern.ircdocs.horse/#targmax-parameter for context. + """ + + MULTI_PRIVMSG = "PRIVMSG multiple targets with one command" + """ + Ability to PRIVMSG multiple targets on a single PRIVMSG line, e.g. + `PRIVMSG alice,bob :hi there`; see + https://modern.ircdocs.horse/#targmax-parameter for context. + """ + NO_CTCP = "+C no-CTCP mode" """ Widely implemented +C mode that blocks CTCPs From 4b12034497826e8f2fe49e3a9a37c86c13d2d5ee Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Sun, 8 Feb 2026 03:45:37 -0500 Subject: [PATCH 2/2] Update irctest/runner.py Co-authored-by: Val Lorentz --- irctest/runner.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/irctest/runner.py b/irctest/runner.py index d3f8fa49..0f5d9b55 100644 --- a/irctest/runner.py +++ b/irctest/runner.py @@ -1,10 +1,6 @@ -from __future__ import annotations - -from typing import TYPE_CHECKING import unittest -if TYPE_CHECKING: - from irctest.specifications import OptionalBehaviors +from irctest.specifications import OptionalBehaviors class NotImplementedByController(unittest.SkipTest, NotImplementedError):