#100DaysOfCode in Python Transcripts
Chapter: Days 10-12: Testing your code with pytest
Lecture: Third day: writing pytest fixtures
Login or
purchase this course
to watch this video and the rest of the course contents.
0:01
Welcome back to the 100 Days of Python.
0:03
Day three of pytest.
0:05
And the final day
0:06
where I want you to get some more exercise.
0:09
And in all honestly, I recorded this lesson
0:13
and something was bugging me.
0:14
Fixtures.
0:15
I mean, fixtures are described
0:18
as the killer feature of pytest
0:19
and I did not cover them.
0:21
But no worries, you will learn them today.
0:24
I made this article explaining
0:26
everything you need to know
0:27
to start to use them in your test code.
0:29
And okay, it's a pretty long article,
0:32
but it's not too hard to actually learn and do.
0:36
There's a practical example in this article.
0:39
If you read through this, then you will see that
0:41
it's pretty easy to set up.
0:43
But it will make your test code a lot better.
0:45
So, I ask you today to come up with a use case,
0:50
so it can be to set up and tear down a database,
0:54
but it doesn't have to be a database.
0:55
It can also be an object of any kind,
0:58
a class, or something that requires
1:00
setUp and tearDown or even only setUp.
1:03
But I really want you to try to learn this skill.
1:05
As you know from unittest,
1:07
setUp and tearDown are commonly used,
1:09
and pytest fixtures are the way to do that.
1:11
So it's critical to understand this.
1:13
That's another day of practical exercises
1:16
and I think by the end of this day,
1:18
you'll have a good grasp on pytest.
1:20
Which will go a long way, because as we mentioned before,
1:23
writing test is a very important skill.
1:26
Good luck and let us know what you come up with.
1:28
Use the #100DaysOfCode and feel to include
1:31
TalkPython or PyBites in your tweets.
1:34
All right, have fun.