|  | 
| 9 | 9 | 00:26 What I do need is to import the actual program. | 
| 10 | 10 | 00:29 So from guess import get random number and the game class. | 
| 11 | 11 | 00:35 Now, one thing I want to show you in this video is how to | 
| 12 |  | -00:38 mark an object. Because Get Random Number, as you can see | 
|  | 12 | +00:38 mock an object. Because Get Random Number, as you can see | 
| 13 | 13 | 00:42 at the right, uses a random integer from start to end. | 
| 14 | 14 | 00:45 And random returns to something randomly every time. | 
| 15 | 15 | 00:49 So how do you actually test that? And the way to do that | 
| 16 |  | -00:52 in testing land is to mark an object. | 
|  | 16 | +00:52 in testing land is to mock an object. | 
| 17 | 17 | 00:54 And for this I'm just going to use the unittest | 
| 18 |  | -00:57 patch method on the mark module | 
|  | 18 | +00:57 patch method on the mock module | 
| 19 | 19 | 01:00 because it's a perfect fit for this scenario. | 
| 20 | 20 | 01:05 So from unittest.mark, import patch. | 
| 21 | 21 | 01:10 I actually need to import to random module | 
|  | 
| 38 | 38 | 02:14 cannot really control and I have another example later | 
| 39 | 39 | 02:17 about the input function where we ask for user input, | 
| 40 | 40 | 02:21 which is another area that can be anything, | 
| 41 |  | -02:24 so you want to mark that out. | 
|  | 41 | +02:24 so you want to mock that out. | 
| 42 | 42 | 02:27 So with this code written, | 
| 43 | 43 | 02:28 let's go back to the command line and run this test. | 
| 44 | 44 | 02:31 And I'm using Control Z on a Mac with foreground to | 
|  | 
0 commit comments