Return Value (Part 2)
And just to prove to you that January 1st, 2019, was a Tuesday I’m going to use the
cal utility and look at
2019 1. So this is—oh, I guess
19? Okay, um,
01 2019. There we go. Okay, so January, 2019, the 1st was a Tuesday.
There we go. So now we have a Tuesday and a Saturday—a weekday and a weekend—captured as
datetime objects. In this case, we want our test to succeed whether it’s a weekday or not, so when we run our test on a weekend, we can change it to be a weekday by patching this
In other words, we want to say “
today is always going to be a weekday.” So first, let’s go ahead and mock
datetime. We’ll say
datetime is a
Mock object. And let’s print the
dir() representation of that
datetime. For now, I’m just going to comment out this assertion. And we’ll clear the screen and run the program again.
Let’s just go ahead and save this, we’ll clear the screen, and run our program again. And we get no output, which is good, which means that an exception didn’t get raised because
is_weekday() is now returning
Become a Member to join the conversation.