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 mock.patch()
calls.
Sometimes instead of patch
I …
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 mock.patch()
calls.
Sometimes instead of patch
I …
When reviewing a pull request against nameko today there was a chunk of code moved from a function into a method, though oterwise mostly unchanged. Unfortunately, it also moved around in the file, and so even git diff -w
(abbreviation for git diff --ignore-all-space
), ignoring all whitespace showed everything as …
Recently I was debugging a strange error when using the eventlet support in the
new the new coverage 4.0
alpha. The issue
manifested itself as a network connection problem: Name or service not known
.
This was confusing, since the host it was trying to connect to was localhost
.
How …
As I work on various projects, I tend to end up with a bunch of git branches lying around in my repo. Every once in a while, I run a git branch --merged
on master to see what can be trivially trimmed, but sometimes the list of unmerged branches grows …
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 moreOften when developing it's easy to let "trivial" edits just slip in without having to jump through all the hoops we put "more serious" patches through. Be this a code-review, running the test suite or any other means of checking over our code: nothing is too small to matter.
A …
read moreOccasionally 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 entries …
At work we use (among other things) puppet to manage our server configurations. For those uninitiated, puppet provides a dsl for specifying server configurations. I won't go into details here, there are plenty of resources elsewhere.
Puppet works by specifying Resources
, describing the desired state of the system. The provisioning …
I use iterm2 as my terminal, and to navigate between tabs, I use cmd-shift-{
and }
. Not infrequently, I mistap and hit cmd-shift-p
instead, which launches the page setup dialog (and in doing so, freezes for a second or so). Now, I rarely (never?) actually need this functionality, and to my …
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 moreFound myself caught by a gotcha using git on os x today. The issue is the way os x (hfs+) handles letter case in file names. File names are case insensitive, which means that File
and file
are considered to be the same file.
To see this in action, create …
read moreI rarely (read: never) want to tweet when I right click to bring up a context menu. Actually, most of the time, I'm just looking for "Inspect Element" in Chrome. I was happily surprised to find I could remove the option entirely:
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 …
Have been thinking about starting to blog for a while. I think the vague plan is to write about code. Mostly notes-to-self a la "How did I get that thing to work again?", but if any of this could be useful to others, all the better. We'll see where this …
read more