Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

This lesson is for members only. Join us and get access to thousands of tutorials and a community of expert Pythonistas.

Unlock This Lesson

Hint: You can adjust the default video playback speed in your account settings.
Hint: You can set the default subtitles language in your account settings.
Sorry! Looks like there’s an issue with video playback 🙁 This might be due to a temporary outage or because of a configuration issue with your browser. Please see our video player troubleshooting guide to resolve the issue.

Add Pseudo-Tests

00:00 So maybe you can either add a second run or adjust line 16 to show what happens when "source" and "target" are not the same, which is the expected behavior. Yeah, that’s a good point.

00:12 Let’s do two runs. Let’s do the first one that doesn’t fail and then a second one that does fail. So Run 2, we want to use—maybe I’m going to change this to invalid_input here …

00:33 where "source" and "target" are the same, so the error is going to get thrown. And here I have some valid_input for the first run, where "source" is 0 and "target" is 1.

00:45 So they’re not the same. So in this case we will see "Done" printed out, and then for the second run, we’re not going to see that. So should I—I should probably give us some indicator that … which run is happening.

01:05 Okay, so with the two print() statements before that, we will see in terminal where we are in the code. Exactly. And then I guess I don’t need these comments anymore.

01:16 Keep it small. Okay, so let’s try that out. Let me clear it first.

01:25 There you go. So we have the first run, that works as expected. "source" and "target" are not the same, no error gets raised, and main() continues past the validation function and prints "Done" that’s here written in line 10, and then starts the second run. In line 20, we print "Run #2".

01:46 And then because "source" and "target" are the same—they’re both 0 as defined in line 21—the SourceEqualsTargetError gets raised.

01:56 Perfect. I think at this point, I would be relatively happy with the code.

Become a Member to join the conversation.