Despite mocks being a bit of a smell, they are handy and I do find myself using them from time to time. As a cheap way to get some extra checks, I try to always make use of
autospec=True in my
Sometimes instead of
patch I …
On one of my sites i have a bunch of different models for various content resources, e.g. articles, videos and podcasts. For admins I wanted to add an "edit this item" link to the menu when browsing the site. Pretty easy: check permissions and add a link to the …read more
Occasionally when using a django
ManyToManyField I find myself wanting to
query the join table directly. Consider for example the models below:
class Category(models.Model): name = models.TextField() class Entry(models.Model): data = models.TextField() categories = models.ManyToManyField(Category)
Suppose I have an
entry, and want to find
One of the projects I work on has a fairly large and old code base, and is unfortunately somewhat lacking in the test suite department. We are working to improve this, but in the medium term we are stuck with a fair amount of manual testing.
As part of some …read more
Sometimes I'd like to know how many database queries were used to generate a particular view, but can't be bothered with the full weight of the (otherwise excellent) django-debug-toolbar.
The toolbar does a lot of logging and slows down rendering. Also, by default I want
'INTERCEPT_REDIRECTS': False, but then I …