Commits

Michael Elsdörfer  committed ae02507

Added a test for implementing custom Command.handle() implementations.

  • Participants
  • Parent commits 2da2a69

Comments (0)

Files changed (1)

         print name
 
 
+class CommandWithCustomHandle(Command):
+
+    def handle(self, app, prog, name, remaining_args):
+        print prog, name, remaining_args
+
+
 class TestCommands(unittest.TestCase):
 
     TESTING = True
             ["--name=joe", "--url=reddit.com"])
         assert 'hello joe from reddit.com' in sys.stdout.getvalue()
 
+    def test_command_with_custom_handle_method(self):
+        manager = Manager(self.app)
+        manager.add_command("handle", CommandWithCustomHandle())
+        sys.argv = ["manage.py", "handle", "pos1", "pos2", "--bar"]
+        try:
+            manager.run()
+        except SystemExit, e:
+            assert e.code == 0
+        assert "manage.py handle ['pos1', 'pos2', '--bar']" in sys.stdout.getvalue()
+
     def test_get_usage(self):
 
         manager = Manager(self.app)