diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/commands/global_test.py | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/tests/commands/global_test.py b/tests/commands/global_test.py index 860a6ccb..c3516a7a 100644 --- a/tests/commands/global_test.py +++ b/tests/commands/global_test.py @@ -116,3 +116,34 @@ class TestComposeCommand(unittest.TestCase): self.assertFalse(envelope.sign) self.assertIs(envelope.sign_key, None) + + +class TestExternalCommand(unittest.TestCase): + + class Success(Exception): + pass + + def on_success(self): + raise self.Success + + def test_no_spawn_no_stdin_success(self): + cmd = g_commands.ExternalCommand( + u'true', + refocus=False, on_success=self.on_success) + with self.assertRaises(self.Success): + cmd.apply(mock.Mock()) + + def test_no_spawn_stdin_success(self): + cmd = g_commands.ExternalCommand( + u"awk '{ exit $0 }'", + stdin=u'0', refocus=False, on_success=self.on_success) + with self.assertRaises(self.Success): + cmd.apply(mock.Mock()) + + def test_no_spawn_failure(self): + ui = mock.Mock() + cmd = g_commands.ExternalCommand( + u'false', + refocus=False, on_success=self.on_success) + cmd.apply(ui) + ui.notify.assert_called_once_with('', priority='error') |