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. All we have to do is try to call the code that's going to crash. And make sure we do that within a with block
0:09 here we say, with pytest.raises say the exception type or something that derives from that exception type. And it'll get caught here.
0:18 If that doesn't happen it just floats the exception, fly through which of course is going to crash the test.
0:24 Just use pytest.raises and you can test for errors.


Talk Python's Mastodon Michael Kennedy's Mastodon