Python for the .NET developer 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.
0:02 It's called unittest.
0:04 All lowercase, just import unittest.
0:06 And it's good. I've used it for many things.
0:08 There's another one, though
0:09 an external one that has definitely got more momentum
0:12 and is used, I would say, more often
0:15 at least at the high-end level.
0:17 So there's a project called pytest.
0:20 Pytest is a super simple way
0:21 for us to write unittests in Python.
0:24 You can see in this first little code block right here
0:27 we have a function called increment.
0:29 And in order to test it we just have to write a function
0:32 with the word test_, the prefix test_
0:36 and pytest will find it and run it for you.
0:38 Totally easy.
0:39 So you can definitely use this built-in unittest one
0:42 and there's no problem with that.
0:43 You would certainly choose that if you didn't want
0:46 to have external dependencies.
0:47 It has a JUnit style of programming
0:50 so if you like that kind of style
0:52 then you'll like the built-in unittest.
0:54 But you also might want to look at pytest.
0:55 There's a bunch of cool plug-ins
0:57 and other things that really enhance it
0:59 and make it probably the best choice these days.