Getting started with pytest Transcripts
Chapter: Parametrization
Lecture: Stacking function parameters

Login or purchase this course to watch this video and the rest of the course contents.
0:00 What if we really did care about the summary for some reason and so I'm going back on this. I want to show you stacked parameters and this is fun
0:10 So I've got a parameterizing start state and what if I wanna parameter rise the summary too. But I don't want to do it like one summary for todo
0:21 one for in prog for done. I want to really have them all match up commonetrically let's just stack these up
0:29 So instead of doing instead of doing start summary here I'm gonna do it as a stack thing. Let's do start summary and not to do in Prog done but
0:43 we'll do like one and two and I'm intentionally doing a different set to two instances that go into start summary and three that go into start state.
0:54 What happens then smarty pants start summary and we'll place replace that there.
1:06 We don't need this for our testing our cards application but I just want to see what happens. pytest -V,
1:13 Test func stacked. Look at that it's doing how many? 123456. It's doing six of these because for each start state it's doing a start
1:30 a start summary of one and a start summary of two. So to do as one and two in Prog has one and two done has one and two and you'll notice the order.
1:41 The order is from bottom to top it doesn't matter which order these are in. So if we swap these around and put start state on the top and start summary
1:51 then we'll get the other orders. So we had the start state and then the summary like that.
1:59 Now if we swap it around it's a summary and then start state. I kind of like to if I'm gonna start stack these up just to keep these
2:08 straight in my head. I like to have the the order that the test node shows. I like to have that be in the same order as the
2:18 parameters to the test. Even though it doesn't really matter to pytest, it matters to me when I'm looking things up.
2:25 Start summary is first in the list. So I like to have it right there right on top of the test function. And then as I'm stacking to the right,
2:36 I'm stacking up for parameters. So we could even have another one if we wanted to. Doesn't even matter if we use it. If we just do foo and 134.
2:52 Sure Why Not? Doesn't matter. But we need to list it. That's a whole bunch of test cases.
3:01 Actually. Isn't that funny. So I'm actually not using foo anywhere in here.
3:06 So if you're in one of those jobs where you get kudos for actually just adding test cases. This is a real easy way to just multiply your test cases out
3:16 without doing a whole lot of work but we don't need that there. We'll leave the stacked one just for fun for people to play with.
3:26 Now I think we're ready to move on to fix your parameterization.


Talk Python's Mastodon Michael Kennedy's Mastodon