Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial


Diallo West
Diallo West
15,069 Points

I'm having a very difficult time understanding testing and how to apply it to my code.

This is some of the code I have for the work log w/database project.

I don't get how to test any of these. I've looked at mock testing, patching and side_effects yet I don't seem to understand how to test what I want my functions to do if they don't fit into an operation ie. x > y or x=y. Please help. I don't have access to slack while at work.

def save_entry(entry): """Entry saved in database""" clear() Entry.create(**entry) print("Entry saved!") return entry

def edit_entry(index, entries): """Edit an entry""" clear() entry = entries[index] print('Edit Entry\n') single_entry(entry) print('\n[T]ask name\n[D]ate\nTime [S]pent\n[N]otes') sel = input('\nChoose an option to edit').lower().strip() while Ture: clear() if sel == 't': edit = edit_task(entry) return edit elif sel == 'd': edit = edit_date(entry) return edit elif sel == 's': edit = edit_time(entry) return edit elif sel == 'n': edit = edit_notes(entry) return edit else: input('Please make a valid selection. Press ENTER. \n')