Python for .NET Developers Transcripts
Chapter: Testing
Lecture: Introducing pytest

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Python comes with a built-in testing framework. It's called unittest. All lowercase, just import unittest. And it's good. I've used it for many things.
0:09 There's another one, though an external one that has definitely got more momentum and is used, I would say, more often at least at the high-end level.
0:18 So there's a project called pytest. Pytest is a super simple way for us to write unittests in Python.
0:25 You can see in this first little code block right here we have a function called increment. And in order to test it we just have to write a function
0:33 with the word test_, the prefix test_ and pytest will find it and run it for you. Totally easy. So you can definitely use this built-in unittest one
0:43 and there's no problem with that. You would certainly choose that if you didn't want to have external dependencies. It has a JUnit style of programming
0:51 so if you like that kind of style then you'll like the built-in unittest. But you also might want to look at pytest. There's a bunch of cool plug-ins
0:58 and other things that really enhance it and make it probably the best choice these days.


Talk Python's Mastodon Michael Kennedy's Mastodon