Python for the .NET developer Transcripts
Chapter: Testing
Lecture: Concept: Testing for errors

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Testing for errors with pytest is easy.
0:02 All we have to do is try to call
0:04 the code that's going to crash.
0:05 And make sure we do that within a with block
0:08 here we say, with pytest.raises
0:11 say the exception type or
0:13 something that derives from that exception type.
0:16 And it'll get caught here.
0:17 If that doesn't happen
0:19 it just floats the exception, fly through
0:21 which of course is going to crash the test.
0:23 Just use pytest.raises and you can test for errors.