Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Python Testing!
You have completed Python Testing!
If your code raises exceptions it's a good idea to test them to make sure they get raised properly. Luckily `unittest` provides a mechanism for this.
New terms
assertRaises(x) - Make sure the following code raises the x
exception
You can use @unittest.expectedFailure
on tests that you know will fail
Example
with assertRaises(ValueError):
int('a')
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up