 I want to talk about a library called Mock. Mock is currently, it's in the standard library as of three, four, I'm looking at Eric. Three, three actually. But in Python two six onwards, it's just a pip install away. Mock, right, let's just import Mock. Just to show you a bit how it works. Mock creates these mock objects that are used for testing, right? So these objects that kind of respond will have every attribute and have every method. So you can kind of stick them everywhere. So let me just create a Mock. And this is my Mock. Nothing more complicated than that. All right, here we go. Mock follows the basic principle of doc testing. Mock has all the attributes you want. And so we had a base Mock, we asked an attribute, it's another Mock, it's all marshmallows all the way down, Mock's after Mock's after Mock's. They all have methods which can call and give its own Mock itself, right? And you can do, you can go as far as you want. It just does not end, right? And you will always get something and it always return something. So, and you can call all these with as many arguments you want, keywords, whatever. And it'll still work, won't complain. And afterwards you can check what's being called on it, right? So this is how you do a test, right? So I have this random method which does something to my object. I don't want to instantiate that object because it creates a database connection and downloads the 15 minutes worth of data from Wikipedia, whatever. I just create a Mock, takes three seconds, send it in. And afterwards check has been called with the right things, right? So here you'll get a listing of the arguments past to the method and the keyword arguments. And you can also get a historical listing. So if you call multiple times, you can get a list about the listings. You can also set a return value if that's how your function works. So when I call my Mock, it now returns a string Mock. As simple as that. Something else that I really find useful in the Mock library which is really trivial but I use all the time is sentinels, sentinel values. Let me create a simple function. So foozer just calls foo on these object A. This being Python, there's no types. So it can be any object as long as it has the method A like my mysterious Mock objects, right? So the sentinel values, so there's this thing called sentinel in the Mock class. All you do is you do dot blah and it has it right away. So in this case this bar can be anything you want and they always equal to each other. But they're not strings, right? So if you're scared of passing a string because it could pass some tests but not others, just send the sentinel value and it'll break where it needs to break but still match what you need to batch. So in case my foozer, right, where I'm doing A dot foo B, I don't care what B is. So I'm gonna pass in the sentinel to make sure that my function here actually passes B into A. So use my Mock, Mock dot sentinel of B bar and then check it again. Call args, it was called of sentinel bar. Now the final thing in the Mock library which I really love is patch, right? Patch is super useful in refactoring. So let's write a really crummy function. Yeah, yeah, I write Python, I don't need stuff from Java like dependency injection or storing variables or anything like that, right? What's the first step to refactoring, right? This is the first thing, Martin Fowler's book, first in the title, anybody? Unit testing. So you've got a crappy function, you need the unit testing before you can do any refactoring. Otherwise, you're just messing around with code, okay? Well, how do you unit test this, right? Because every time you run the test, it's gonna create a connection. If you don't have this thing called home which you can reach from your machine, it's just gonna fail miserably. Well, this is where Mock dot patch comes in, really useful. It's a decorator. So let me just set up my Mock here. Use it as decorator. So what I'm saying is I'm giving the actual library in the patch here, so socket dot create connection. I'm telling it go into there and mock out create connection with this. So in my test, I run my test and my Mock will be, so this value Mock, and I give a return value my Mock, so for this function, it's gonna become this, it's gonna return my Mock, gonna send hello. So now I can check for that and the call arcs and run it and it passes magically enough. Handier is without the second argument where it will automatically create a Mock for you and pass it as an argument to your test and then you can use it in your test doing whatever you want it to do. And I have to type really fast because I run out of time and it'll do exactly what you want it, what you think it'll do. This also works, I just used functions here, but it works with the unit test library and methods in the unit test class. Thank you very much.