summaryrefslogtreecommitdiff
path: root/cliff/tests/test_help.py
diff options
context:
space:
mode:
Diffstat (limited to 'cliff/tests/test_help.py')
-rw-r--r--cliff/tests/test_help.py49
1 files changed, 13 insertions, 36 deletions
diff --git a/cliff/tests/test_help.py b/cliff/tests/test_help.py
index bdf9d71..db106a5 100644
--- a/cliff/tests/test_help.py
+++ b/cliff/tests/test_help.py
@@ -6,39 +6,8 @@ except:
import mock
from cliff.app import App
-from cliff.command import Command
-from cliff.commandmanager import CommandManager
from cliff.help import HelpCommand
-
-
-class TestParser(object):
-
- def print_help(self, stdout):
- stdout.write('TestParser')
-
-
-class TestCommand(Command):
-
- @classmethod
- def load(cls):
- return cls
-
- def get_parser(self, ignore):
- # Make it look like this class is the parser
- # so parse_args() is called.
- return TestParser()
-
- def take_action(self, args):
- return
-
-
-class TestCommandManager(CommandManager):
- def _load_commands(self):
- self.commands = {
- 'one': TestCommand,
- 'two words': TestCommand,
- 'three word command': TestCommand,
- }
+from cliff.tests import utils
def test_show_help_for_command():
@@ -46,7 +15,9 @@ def test_show_help_for_command():
# do commands know too much about apps by using them to get to the
# command manager?
stdout = StringIO()
- app = App('testing', '1', TestCommandManager('cliff.test'), stdout=stdout)
+ app = App('testing', '1',
+ utils.TestCommandManager(utils.TEST_NAMESPACE),
+ stdout=stdout)
app.NAME = 'test'
help_cmd = HelpCommand(app, mock.Mock())
parser = help_cmd.get_parser('test')
@@ -63,7 +34,9 @@ def test_list_matching_commands():
# do commands know too much about apps by using them to get to the
# command manager?
stdout = StringIO()
- app = App('testing', '1', TestCommandManager('cliff.test'), stdout=stdout)
+ app = App('testing', '1',
+ utils.TestCommandManager(utils.TEST_NAMESPACE),
+ stdout=stdout)
app.NAME = 'test'
help_cmd = HelpCommand(app, mock.Mock())
parser = help_cmd.get_parser('test')
@@ -83,7 +56,9 @@ def test_list_matching_commands_no_match():
# do commands know too much about apps by using them to get to the
# command manager?
stdout = StringIO()
- app = App('testing', '1', TestCommandManager('cliff.test'), stdout=stdout)
+ app = App('testing', '1',
+ utils.TestCommandManager(utils.TEST_NAMESPACE),
+ stdout=stdout)
app.NAME = 'test'
help_cmd = HelpCommand(app, mock.Mock())
parser = help_cmd.get_parser('test')
@@ -103,7 +78,9 @@ def test_show_help_for_help():
# do commands know too much about apps by using them to get to the
# command manager?
stdout = StringIO()
- app = App('testing', '1', TestCommandManager('cliff.test'), stdout=stdout)
+ app = App('testing', '1',
+ utils.TestCommandManager(utils.TEST_NAMESPACE),
+ stdout=stdout)
app.NAME = 'test'
help_cmd = HelpCommand(app, mock.Mock())
parser = help_cmd.get_parser('test')