From 84cc75c749f2f2ac656b48213dd6b848f4e18ed4 Mon Sep 17 00:00:00 2001 From: Tom Smith <142233216+tomsmith8@users.noreply.github.com> Date: Fri, 15 Nov 2024 09:18:29 +0000 Subject: [PATCH] Create test_todo.py --- test_todo.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 test_todo.py diff --git a/test_todo.py b/test_todo.py new file mode 100644 index 0000000..cfd0641 --- /dev/null +++ b/test_todo.py @@ -0,0 +1,23 @@ +# test_todo.py + +import unittest +from todo import Todo + +class TestTodo(unittest.TestCase): + + def setUp(self): + self.todo = Todo() + + def test_add_task(self): + # Test adding a valid task + result = self.todo.add_task("Buy milk") + self.assertIn("Task 'Buy milk' added.", result) + self.assertIn("Buy milk", self.todo.get_tasks()) + + def test_add_empty_task(self): + # Test adding an empty task, should raise ValueError + with self.assertRaises(ValueError): + self.todo.add_task("") + +if __name__ == "__main__": + unittest.main()