tests: Replace deprecated assertRaisesRegexp with assertRaisesRegex.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
564fc0e527
commit
e8bb65b188
|
@ -154,7 +154,7 @@ class BotTestCase(unittest.TestCase):
|
||||||
|
|
||||||
def validate_invalid_config(self, config_data: Dict[str, str], error_regexp: str) -> None:
|
def validate_invalid_config(self, config_data: Dict[str, str], error_regexp: str) -> None:
|
||||||
bot_class = type(get_bot_message_handler(self.bot_name))
|
bot_class = type(get_bot_message_handler(self.bot_name))
|
||||||
with self.assertRaisesRegexp(ConfigValidationError, error_regexp):
|
with self.assertRaisesRegex(ConfigValidationError, error_regexp):
|
||||||
bot_class.validate_config(config_data)
|
bot_class.validate_config(config_data)
|
||||||
|
|
||||||
def validate_valid_config(self, config_data: Dict[str, str]) -> None:
|
def validate_valid_config(self, config_data: Dict[str, str]) -> None:
|
||||||
|
|
|
@ -129,10 +129,7 @@ class BotServerTests(BotServerTestCase):
|
||||||
"token": "abcd1234",
|
"token": "abcd1234",
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
# This works, but mypy still complains:
|
with self.assertRaisesRegex(
|
||||||
# error: No overload variant of "assertRaisesRegexp" of "TestCase" matches argument types
|
|
||||||
# [def (*args: builtins.object, **kwargs: builtins.object) -> builtins.SystemExit, builtins.str]
|
|
||||||
with self.assertRaisesRegexp(
|
|
||||||
SystemExit,
|
SystemExit,
|
||||||
'Error: Bot "nonexistent-bot" doesn\'t exist. Please make '
|
'Error: Bot "nonexistent-bot" doesn\'t exist. Please make '
|
||||||
"sure you have set up the botserverrc file correctly.",
|
"sure you have set up the botserverrc file correctly.",
|
||||||
|
@ -254,7 +251,7 @@ class BotServerTests(BotServerTestCase):
|
||||||
assert isinstance(module, ModuleType)
|
assert isinstance(module, ModuleType)
|
||||||
|
|
||||||
# load invalid module name
|
# load invalid module name
|
||||||
with self.assertRaisesRegexp(
|
with self.assertRaisesRegex(
|
||||||
SystemExit,
|
SystemExit,
|
||||||
'Error: Bot "botserver-test-case-random-bot" doesn\'t exist. '
|
'Error: Bot "botserver-test-case-random-bot" doesn\'t exist. '
|
||||||
"Please make sure you have set up the botserverrc file correctly.",
|
"Please make sure you have set up the botserverrc file correctly.",
|
||||||
|
@ -264,7 +261,7 @@ class BotServerTests(BotServerTestCase):
|
||||||
]
|
]
|
||||||
|
|
||||||
# load invalid file path
|
# load invalid file path
|
||||||
with self.assertRaisesRegexp(
|
with self.assertRaisesRegex(
|
||||||
SystemExit,
|
SystemExit,
|
||||||
'Error: Bot "{}/zulip_bots/zulip_bots/bots/helloworld.py" doesn\'t exist. '
|
'Error: Bot "{}/zulip_bots/zulip_bots/bots/helloworld.py" doesn\'t exist. '
|
||||||
"Please make sure you have set up the botserverrc file correctly.".format(root_dir),
|
"Please make sure you have set up the botserverrc file correctly.".format(root_dir),
|
||||||
|
|
Loading…
Reference in a new issue