Skip to content

Commit e8bb65b

Browse files
committed
tests: Replace deprecated assertRaisesRegexp with assertRaisesRegex.
Signed-off-by: Anders Kaseorg <[email protected]>
1 parent 564fc0e commit e8bb65b

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

zulip_bots/zulip_bots/test_lib.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def verify_dialog(self, conversation: List[Tuple[str, str]]) -> None:
154154

155155
def validate_invalid_config(self, config_data: Dict[str, str], error_regexp: str) -> None:
156156
bot_class = type(get_bot_message_handler(self.bot_name))
157-
with self.assertRaisesRegexp(ConfigValidationError, error_regexp):
157+
with self.assertRaisesRegex(ConfigValidationError, error_regexp):
158158
bot_class.validate_config(config_data)
159159

160160
def validate_valid_config(self, config_data: Dict[str, str]) -> None:

zulip_botserver/tests/test_server.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,7 @@ def test_wrong_bot_credentials(
129129
"token": "abcd1234",
130130
}
131131
}
132-
# This works, but mypy still complains:
133-
# error: No overload variant of "assertRaisesRegexp" of "TestCase" matches argument types
134-
# [def (*args: builtins.object, **kwargs: builtins.object) -> builtins.SystemExit, builtins.str]
135-
with self.assertRaisesRegexp(
132+
with self.assertRaisesRegex(
136133
SystemExit,
137134
'Error: Bot "nonexistent-bot" doesn\'t exist. Please make '
138135
"sure you have set up the botserverrc file correctly.",
@@ -254,7 +251,7 @@ def test_load_lib_modules(self) -> None:
254251
assert isinstance(module, ModuleType)
255252

256253
# load invalid module name
257-
with self.assertRaisesRegexp(
254+
with self.assertRaisesRegex(
258255
SystemExit,
259256
'Error: Bot "botserver-test-case-random-bot" doesn\'t exist. '
260257
"Please make sure you have set up the botserverrc file correctly.",
@@ -264,7 +261,7 @@ def test_load_lib_modules(self) -> None:
264261
]
265262

266263
# load invalid file path
267-
with self.assertRaisesRegexp(
264+
with self.assertRaisesRegex(
268265
SystemExit,
269266
'Error: Bot "{}/zulip_bots/zulip_bots/bots/helloworld.py" doesn\'t exist. '
270267
"Please make sure you have set up the botserverrc file correctly.".format(root_dir),

0 commit comments

Comments
 (0)