diff options
author | 2020-05-18 16:18:40 +0300 | |
---|---|---|
committer | 2020-05-18 16:18:40 +0300 | |
commit | cf89c5be49bfe57934d2fea9408a44f78c4db3b6 (patch) | |
tree | 6fef7f6a61f0771cf7f535490c136a4865fd5897 | |
parent | EH Tests: Added test for `CommandInvokeError` handling on handler (diff) |
EH Tests: Added test for 3 errors handling on handler
These 3 errors is:
- `ConversionError`
- `MaxConcurrencyReached`
- `ExtensionError`
-rw-r--r-- | tests/bot/cogs/test_error_handler.py | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/bot/cogs/test_error_handler.py b/tests/bot/cogs/test_error_handler.py index 09543b56d..bc67e9d7c 100644 --- a/tests/bot/cogs/test_error_handler.py +++ b/tests/bot/cogs/test_error_handler.py @@ -1,5 +1,5 @@ import unittest -from unittest.mock import AsyncMock, patch +from unittest.mock import AsyncMock, MagicMock, patch from discord.ext.commands import errors @@ -135,3 +135,19 @@ class ErrorHandlerTests(unittest.IsolatedAsyncioTestCase): with self.subTest(args=case["args"], expect_mock_call=case["expect_mock_call"]): self.assertIsNone(await cog.on_command_error(*case["args"])) case["expect_mock_call"].assert_awaited_once_with(self.ctx, case["args"][1].original) + + async def test_error_handler_three_other_errors(self): + """Should call `handle_unexpected_error` when `ConversionError`, `MaxConcurrencyReached` or `ExtensionError`.""" + cog = ErrorHandler(self.bot) + cog.handle_unexpected_error = AsyncMock() + errs = ( + errors.ConversionError(MagicMock(), MagicMock()), + errors.MaxConcurrencyReached(1, MagicMock()), + errors.ExtensionError(name="foo") + ) + + for err in errs: + with self.subTest(error=err): + cog.handle_unexpected_error.reset_mock() + self.assertIsNone(await cog.on_command_error(self.ctx, err)) + cog.handle_unexpected_error.assert_awaited_once_with(self.ctx, err) |