diff options
| author | 2020-05-19 08:18:55 +0300 | |
|---|---|---|
| committer | 2020-05-19 08:18:55 +0300 | |
| commit | 33231d5881063c720ab54b295d36030b4b304002 (patch) | |
| tree | 995f8508aab4d3b8946a273119a0bff52908b72b | |
| parent | EH Tests: Cleanup `try_silence` tests (diff) | |
EH Tests: Added tests for `get_help_command`in `OtherErrorHandlerTests`
| -rw-r--r-- | tests/bot/cogs/test_error_handler.py | 32 | 
1 files changed, 32 insertions, 0 deletions
| diff --git a/tests/bot/cogs/test_error_handler.py b/tests/bot/cogs/test_error_handler.py index bfb1cfe61..615c0e455 100644 --- a/tests/bot/cogs/test_error_handler.py +++ b/tests/bot/cogs/test_error_handler.py @@ -229,3 +229,35 @@ class TrySilenceTests(unittest.IsolatedAsyncioTestCase):          """Should return `False` when message don't match."""          self.ctx.invoked_with = "foo"          self.assertFalse(await self.cog.try_silence(self.ctx)) + + +class OtherErrorHandlerTests(unittest.IsolatedAsyncioTestCase): +    """Other `ErrorHandler` tests.""" + +    def setUp(self): +        self.bot = MockBot() +        self.ctx = MockContext() + +    async def test_get_help_command_command_specified(self): +        """Should return coroutine of help command of specified command.""" +        self.ctx.command = "foo" +        result = ErrorHandler.get_help_command(self.ctx) +        expected = self.ctx.send_help("foo") +        self.assertEqual(result.__qualname__, expected.__qualname__) +        self.assertEqual(result.cr_frame.f_locals, expected.cr_frame.f_locals) + +        # Await coroutines to avoid warnings +        await result +        await expected + +    async def test_get_help_command_no_command_specified(self): +        """Should return coroutine of help command.""" +        self.ctx.command = None +        result = ErrorHandler.get_help_command(self.ctx) +        expected = self.ctx.send_help() +        self.assertEqual(result.__qualname__, expected.__qualname__) +        self.assertEqual(result.cr_frame.f_locals, expected.cr_frame.f_locals) + +        # Await coroutines to avoid warnings +        await result +        await expected | 
