Getting started with pytest Transcripts
Chapter: pytest Fixtures
Lecture: Tracing execution with --setup-show
0:00 Set up and tear down is so in green and so crucial. And part of how fixtures work, pytest has a really cool tracing function here.
0:11 So when you're working with fixtures, sometimes, especially with multiple fixtures,
0:15 you might really lose track of what's happening when in our example here,
0:19 I've used print statements but usually you're not gonna have print statements around. So let's take a look at this.
0:25 This example, again, the last example we did was the context manager fixture and instead of printing it out, so if we didn't have all the printouts,
0:34 printouts, we just see that. But pytest allows you to do a setup show which is really cool to trace what's going on within your fixtures.
0:44 So it'll run the test but it will tell you exactly the order of things are going on. So it's showing you that it's uh setting up the DB and it's
0:56 a this is a fixture name, so it's the DB fixture And then it's running this test and it lists the fixtures
1:04 used because sometimes there's more than one and then it does the showing the tear down this f is talking about scope and we'll talk about scope later.
1:13 I haven't specified the scope area. So if I did, it would be in this inside the fixture call but the
1:20 default is function scope and that means that it this, if I had a multiple tests, it would run before and after each test.