#100DaysOfCode in Python Transcripts
Chapter: Days 10-12: Testing your code with pytest
Lecture: Second day: use pytest on your code
Login or
purchase this course
to watch this video and the rest of the course contents.
0:00
Welcome back to the hundred days of Python.
0:02
This is day two of the pytest lesson.
0:05
Yesterday, we went over quite some concepts,
0:08
and now it's time to get practical.
0:10
So here, I pointed to a code challenge,
0:17
which is, not surprisingly, writing tests with pytest,
0:22
and it consists of going through your code,
0:25
see where tests are missing, and add them.
0:28
Another option is to test a Flask API,
0:31
or even contribute to open source.
0:34
There's a lot of great work being done,
0:36
and not all might have test coverage.
0:38
It might be a useful way to get into those projects,
0:41
to start adding tests.
0:43
So basically that, if you want to follow along,
0:45
you can clone our challenges repo
0:48
and make a branch and PR your work,
0:51
because we're always curious to see what you come up with.
0:54
Another way, if you want to just look at some tests,
0:58
is to head over to our bites.
0:59
Every bite is tested with a couple of pytests,
1:02
so each bite under the tests tab shows you pytest in action.
1:16
And a day generator...
1:24
And here is the exceptions being tested by pytest again.
1:28
One syntax we did not see is the pytest .fail.
1:32
This basically where it raises an exception
1:34
when it should not have, alright.
1:39
Then I want to point you to one more resource
1:42
and that's Brian Okken's Test and Code.
1:47
He has this podcast dedicated to testing in Python
1:52
and he is the author of Python Testing with Pytest
1:57
which is a great book.
1:58
I only showed you a couple of things.
2:01
This book goes in detail on how
2:03
to set up pytest configuration, fixtures, and a lot more.
2:08
So if you're serious about pytest, this is a great resource.
2:12
And that's it, today is all about getting practical
2:15
and tomorrow I'll check back in with you how it is going.
2:18
Good luck.