From 4ca7f9ffce68d737642071f5dffaa78a738d8520 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 2 Aug 2018 10:23:04 -0700 Subject: commands/globals: Convert CallCommand.apply to a coroutine This allows it to easily wrap calls that are themselves coroutines, while it's still able to wrap synchronous calls. This fixes the async test and allows hooks that are coroutines to work. --- tests/commands/global_test.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/commands/global_test.py b/tests/commands/global_test.py index 1122b3f7..48ddd34d 100644 --- a/tests/commands/global_test.py +++ b/tests/commands/global_test.py @@ -246,14 +246,15 @@ class TestExternalCommand(unittest.TestCase): class TestCallCommand(unittest.TestCase): - def test_synchronous_call(self): + @utilities.async_test + async def test_synchronous_call(self): ui = mock.Mock() cmd = g_commands.CallCommand('ui()') - cmd.apply(ui) + await cmd.apply(ui) ui.assert_called_once() - @unittest.expectedFailure - def test_async_call(self): + @utilities.async_test + async def test_async_call(self): async def func(obj): obj() @@ -264,5 +265,5 @@ class TestCallCommand(unittest.TestCase): with mock.patch('alot.commands.globals.settings.hooks', hooks): cmd = g_commands.CallCommand('hooks.func(ui)') - cmd.apply(ui) + await cmd.apply(ui) ui.assert_called_once() -- cgit v1.2.3