Django Manager Testing Woes
I've recently run into some strange behavior while testing some custom Django managers. While, I can't list all of the exact code (it's not open source), I'll try to list some simple examples that illustrate the problem so (hopefully), this post will be helpful for others. To get started, assume I have the following Model and Manager: class DefaultThingManager(models.Manager): def things(): # A custom method that retrieves some set of DefaultThing # objects. This doesn't ...
Published: 2013-03-15
How in the world do you Mock a name attribute?
Or... My adventures with Mock. Part 1. I've been working a lot with Mock lately (and by lately, I meand for the last three months). Though it takes a while to wrap your head around it, it's an amazing and powerful testing tool. To get started, let's look at some of the neat things you can do with Mock. Take this class, for example: class Thing(object): shape = 'square' color = 'blue' def calculate(self): # ... do some stuff ...