Getting started with pytest Transcripts
Chapter: pytest Fixtures
Lecture: Finding where fixtures are defined
0:01 We haven't talked about built in fixtures yet, so that's what we're gonna talk about now and it's gonna come around trying to
0:10 get rid of this temporary directory thing here. it's, works but there's a cleaner way and I also want to address
0:18 one topic before we move on and that is I've got these, these different test files that one of the issues with having fixtures in a conftest file
0:29 and contest files that can be one for directory. So in theory I can have time in my project and or my
0:43 pytest course directory in chapter three in fixture sharing, I could have a conftest file here,
0:51 I could have one in chapter three also and I could have one up at the
0:54 Pytest course level conceptually and any of those places could be where my fixture lives, you could share them like that.
1:02 So how do you tell where they are? So if I'm just looking at the test file, I know this Cards_db is here and I need to know where it is.
1:10 Well I can use pytest to show me where it is. So if I, if I'm in this directory where I'm at, I'm in chapter three right now.
1:20 I want to go into the fixture sharing directory run pytest, verify, it works. $ pytest --fixtures is a really cool way
1:30 to find out what fixtures are here and available and it's for this directory for the directory I am in and I can give it a specific test file if I want
1:39 because there might be fixtures in that test file. So let's just go and do that in test one.
1:44 What are the fixtures available? So I've got a bunch actually there, so these are some of the built ins we're going to talk about,
1:52 but at the end I've got the fixtures divided from conftest and it tells me exactly it's got the cards_db on line,
2:01 17 of the contest file and cards_db sessions. So that tells me exactly where these are.
2:07 Unfortunately, I didn't add a doc string so let's let's actually fix that before we move on. So I guess it's kind of nice to have a doc string
2:15 there and I'll show you why. So the cards_db session that is what is that doing?
2:20 It's, we're going to say that this returns a connection to the cards_db and well, so does the other one,
2:36 but this one's special returns and a connection to an empty current e an empty cards_db So this is an empty different one,
2:51 so slightly different. Maybe you can come up with better wording this works and we
2:56 can see how this doc string helps us with this uh this fixtures call, huh?
3:02 Now that, that doc string shows up right there in our help text for fixtures. So,thats pretty cool