Getting started with pytest Transcripts
Lecture: Using -ra to see reasons for all test outcomes
0:00 One more thing I want to talk about before we leave. Our discussion of markers is a thing called -R.
0:08 So it's just an extra flag that we can use to help see what's going on in chapter five. We have a handful of tests already and we have our test
0:17 files we've got our custom one and we have some skip this skip examples skip if an Xfail and are sort let's just run everything.
0:27 But I'm gonna turn off trace backs because I don't want any of the fails I don't need to see tb=no. So what we get the output here is we get green dots
0:39 for all the passing. We get SS for skips, we get the F's for fails and then we've got X fail and X pass here
0:48 and then at the bottom we've got reasons but our reasons for the skips and the Xfails are gone. We can use instead of let's clear that instead of just
1:01 tb no we can turn on -ra. So this is my favorite option for this -r. And that just gives us more information at the end.
1:12 I'll just run it and show you what's going on. So the '-ra' added. So we also already had these failures listed but we also now get reasons for the
1:25 X pass. So the Xpass demo reason for the X fail and reasons for the skips. I like to see all of this in my output even if I'm turning
1:36 off trace backs. So I often run with '-ra'. Now '-ra' means all except for passing.
1:42 So if we did capital A that's all including passing and that's kind of annoying. The default is -'rfE' So failures and errors.
1:53 So that looks like we had before. So you can also specify, you know, fine grain if you want. So if you want to just see the skips,
2:01 you can just say '-rs' and then you can just see the skipped reasons or the X fails. So they are 'x' for 'xfail' and capital X for 'XPASS'
2:12 But you know why do that fine grain stuff. I just remember '-ra'. And then I get it. But now that we've already mucked with our
2:24 pytest any file, let's take a look at that and just stick the '-ra' In there. So here for our pytest, any file, we can just add '-ra'
2:33 And save that and then that should be fine. So if we take that off and just do tb Equals no. Now we get these. Yeah. So what did we do?
2:43 We did the '-ra' flag and stuck it in our addopts along with strict markers.