Ejemplo n.º 1
0
    def test_too_few_args_has_optionals(self, crawl_mock, crawl_mock_main):
        def task(arg1, optional=None):
            """This is my task"""
            pass

        crawl_mock.return_value = task
        crawl_mock_main.return_value = task
        state.env.nodeps = False
        try:
            main.run_tasks([('my task', [], {}, [], [], [])])
        except SystemExit as e:
            self.assertEqual(e.code, 2)
        self.assertEqual('Incorrect number of arguments to task.\n\n'
                         'Displaying detailed information for task '
                         '\'my task\':\n\n    This is my task\n\n',
                         self.test_stdout.getvalue())
Ejemplo n.º 2
0
    def test_too_few_args_has_optionals(self, crawl_mock, crawl_mock_main):
        def task(arg1, optional=None):
            """This is my task"""
            pass

        crawl_mock.return_value = task
        crawl_mock_main.return_value = task
        state.env.nodeps = False
        try:
            main.run_tasks([('my task', [], {}, [], [], [])])
        except SystemExit as e:
            self.assertEqual(e.code, 2)
        self.assertEqual(
            'Incorrect number of arguments to task.\n\n'
            'Displaying detailed information for task '
            '\'my task\':\n\n    This is my task\n\n',
            self.test_stdout.getvalue())