Skip to content

Commit

Permalink
Create test_todo.py
Browse files Browse the repository at this point in the history
  • Loading branch information
tomsmith8 authored Nov 15, 2024
1 parent 59777e8 commit 84cc75c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions test_todo.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 84cc75c

Please sign in to comment.