From 62b47b6f081f8b22479dca79c29409cb45319e25 Mon Sep 17 00:00:00 2001 From: Roy Sommer Date: Wed, 31 Aug 2022 22:22:08 +0300 Subject: handle listing tasks when there are no tasks (#52) --- tests/test_taskipy.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'tests') diff --git a/tests/test_taskipy.py b/tests/test_taskipy.py index 7b67fd3..4b9b347 100644 --- a/tests/test_taskipy.py +++ b/tests/test_taskipy.py @@ -221,6 +221,24 @@ class ListTasksTestCase(TaskipyTestCase): self.assertTerminalTextEqual(expected, stdout.strip()) self.assertEqual(exit_code, 0) + def test_running_task_list_no_tasks(self): + py_project_toml = ''' + [tool.taskipy.tasks] + ''' + cwd = self.create_test_dir_with_py_project_toml(py_project_toml) + exit_code, stdout, _ = self.run_task('--list', cwd=cwd) + + self.assertTerminalTextEqual('no tasks found. create your first task by adding it to your pyproject.toml file under [tool.taskipy.tasks]', stdout.strip()) + self.assertEqual(exit_code, 127) + + def test_running_task_list_no_tasks_section(self): + py_project_toml = '' + cwd = self.create_test_dir_with_py_project_toml(py_project_toml) + exit_code, stdout, _ = self.run_task('--list', cwd=cwd) + + self.assertTerminalTextEqual('no tasks found. add a [tool.taskipy.tasks] section to your pyproject.toml', stdout.strip()) + self.assertEqual(exit_code, 127) + class TaskDescriptionTestCase(TaskipyTestCase): def test_running_task_with_description(self): -- cgit v1.2.3