Exemple #1
0
 def __init__(self, name, desc='You are in a maze of twisty passages, all alike', short_desc='a maze',
              help='It looks like you are completely lost'):
     self._name = str(name)
     self._desc = str(desc)
     self._short_desc = str(short_desc)
     self._help = str(help)
     self._connections = dict()  # direction -> connection
     self._output = Output.getinstance()
 def test_str(self):
     name = 'Test Name'
     obj = Output.getinstance()
     method = obj.print_sentence
     help_text = 'The print_sentence method of the Output singleton'
     instance = Command(name, obj, method, help_text)
     exp_result = name
     result = str(instance)
     self.assertEqual(exp_result, result)
 def test_call(self):
     name = 'Test Name'
     obj = Output.getinstance()
     method = obj.get_sentence
     help_text = 'The get_sentence method of the Output singleton'
     instance = Command(name, obj, method, help_text)
     exp_result = '\n   Some format 5.  '
     result = instance('some format %d', 5)
     self.assertEqual(exp_result, result)
 def test_init(self):
     name = 'Test Name'
     obj = Output.getinstance()
     method = obj.print_sentence
     help_text = 'The print_sentence method of the Output singleton'
     instance = Command(name, obj, method, help_text)
     exp_result = name
     result = instance.name
     self.assertEqual(exp_result, result)
     exp_result = help
     result = instance.help
     self.assertEqual(exp_result, result)
     exp_result = obj
     result = instance._obj
     self.assertEqual(exp_result, result)
     exp_result = method
     result = instance._method
     self.assertEqual(exp_result, result)
 def __init__(self, directions, actions, aliases, errors):
     self._directions = directions
     self._actions = actions
     self._aliases = aliases
     self._errors = errors
     self._output = Output.getinstance()