Getting started with pytest Transcripts
Chapter: Welcome to the course
Lecture: pytest vs. unittest

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's take a look at a simple example of a test and compare pytest versus unittest. In pytest, you just really have a test function starts with test
0:11 underscore and use normal asserts. In unit tests you need to derive from unit test test case. So that means that every test has to be a method in a
0:22 test class. And you can't really use assert. You can but it doesn't give you enough information.
0:28 So there's helper functions like assert equal. With pytest. You can use classes if you want,
0:34 you just don't have to and if you do use test classes you don't derive from
0:39 anything. You could just have a class and you can still use the normal assert.
0:44 These assert helper functions. There's a whole bunch of them in unit test. I'm only listing a few in pytest as I've shown on the left.
0:53 It's just assert. So you any boolean expression can be used in an assert statement


Talk Python's Mastodon Michael Kennedy's Mastodon